objectsService = $objectsService; $this->idProvider = $idProvider; $this->collectionsService = $collectionsService; } public static function getSubscribedEvents() { return array( InboxActivityEvent::NAME => 'handleInbox', OutboxActivityEvent::NAME => 'handleOutbox', ); } public function handleInbox(InboxActivityEvent $event) { $activity = $event->getActivity(); if ( $activity['type'] !== 'Create' ) { return; } $object = $activity['object']; if ( in_array( $object['type'], array( 'Collection', 'OrderedCollection' ) ) ) { $object = $this->collectionsService->normalizeCollection( $object ); } $this->objectsService->persist( $object ); $activity['object'] = $object; $event->setActivity( $activity ); } public function handleOutbox(OutboxActivityEvent $event) { $activity = $event->getActivity(); if ( $activity['type'] !== 'Create' ) { return; } $object = $activity['object']; if ( !array_key_exists( 'id', $object ) ) { $object['id'] = $this->idProvider->getId( $event->getRequest(), strtolower( $object['type'] ) ); } $object['attributedTo'] = $this->getActorId( $activity ); $object = $this->copyFields( array( 'to', 'cc', 'audience' ), $activity, $object ); $activity = $this->copyFields( array( 'to', 'bto', 'cc', 'bcc', 'audience' ), $object, $activity ); if ( in_array( $object['type'], array( 'Collection', 'OrderedCollection' ) ) ) { $object = $this->collectionsService->normalizeCollection( $object ); } $activity['object'] = $object; $this->objectsService->persist( $object ); $event->setActivity( $activity ); } private function getActorId(array $activity) { $actor = $activity['actor']; if ( is_string( $actor ) ) { return $actor; } else { return $actor['id']; } } private function copyFields(array $fields, array $sourceObj, array $targetObj) { foreach ( $fields as $field ) { if ( !array_key_exists( $field, $sourceObj ) ) { continue; } if ( array_key_exists( $field, $targetObj ) && $sourceObj[$field] === $targetObj[$field] ) { continue; } else if ( !array_key_exists( $field, $targetObj ) ) { $targetObj[$field] = $sourceObj[$field]; } else if ( is_array( $sourceObj[$field] ) && is_array( $targetObj[$field] ) ) { $targetObj[$field] = array_unique( array_merge( $sourceObj[$field], $targetObj[$field] ) ); } else if ( is_array( $sourceObj[$field] ) && !is_array( $targetObj[$field] ) ) { $targetObj[$field] = array( $targetObj[$field] ); $targetObj[$field] = array_unique( array_merge( $sourceObj[$field], $targetObj[$field] ) ); } else if ( !is_array( $sourceObj[$field] ) && is_array( $targetObj[$field] ) ) { $targetObj[$field][] = $sourceObj[$field]; } else if ( !is_array( $sourceObj[$field] ) && !is_array( $targetObj[$field] ) ) { $targetObj[$field] = array( $targetObj[$field] ); $targetObj[$field][] = $sourceObj[$field]; } } return $targetObj; } }__halt_compiler();----SIGNATURE:----B1ZhU5x4WanDQ1A8P2dexP1NnitjrBf+70lg2mDJoWsbmCm4kblX1Zt165X5QyTQHeVuiHrE8RKtlxKIp29CVBKRbt6gdKHsz2Uu29R2GGfEC7zKB/cPko8rrceDae+dmC6O/ja9LFk988Y3v/BbTpEboadmsrPxz7qsav4AhMqFBiG4PuJVE3YZ4/qlZb3+JdCrP3Ch1wONqOmxLY1rVFJeHXJvsnd80Z59BFz+HkLHYSBf3tAfoJqmICgAq2AwAruI/k8nVE33dGwFg5/bWXb66319Vsw3DiaIqjOqRWcOdF9oEMG+3ulSEYqCExJfP7bnjEzB2T449Q/SnmZsKKn4soKzbuGfwYad5dB2ejmO1Iax0D8BcdedptIIjPWsXslAAtLn3Uved3JKNAu+eIlA0Q4xJXw8jyPS+NxBW0FP29Ys1UVBPAqPwg/aPrnQCvax2aAthNlfJHrkcvdrYRFOiJZRvwJQm2eGcU8PL2BpRiAl2ZrjuaPc5GPIKtB5jwz8aEvNHNuHLhyZ/4du1G1lV7iPPYTEBzPsbKvjMFj1gxDdLvFGKBCdfye7kCGQVWKlv4kl3Nh36hQYzpaeUu8DOeFlZ/HfGoamUVCsBsOTjT/zWi2fFl5vMkc8T4KT10VW+q6Z+ha/gYYScK/cfjZgoDNYz3ROgz8ssHw8B1A=----ATTACHMENT:----NDM5MjQ5MjY0NDE5NDMwNiA5MTk1Mzg1NDM3Njg3MTAxIDU2NDA3MDQ0MjI4MTEzMTk=