protected function _actionAdd($context)
    {
        $data = $context->data;

        $entity = parent::_actionAdd($context);

        //if a person posting a message on his profile
        //or if a target is not actor then it can't be a private message
        if (get_viewer()->eql($this->actor) || !is_person($this->actor)) {
            unset($data->private);
        }

        //if a private message then
        //set the privacy to subject/target
        if ($data->private) {
            $entity->setAccess(array($this->actor->id, get_viewer()->id));
        }

        //create a notification for the subscribers and
        //the post owner as well
        if ($entity->owner->isSubscribable()) {
            //create a notification and pass the owner
            $notification = $this->createNotification(array(
                'name' => 'note_add',
                'object' => $entity,
                'subscribers' => array($entity->owner->subscriberIds->toArray(), $entity->owner),
            ))->setType('post', array('new_post' => true));
        }

        if (!empty($data['channels'])) {
            $this->shareObject(array(
                'object' => $entity,
                'sharers' => $data['channels']
            ));
        }

        return $entity;
    }
protected function _actionAdd($context)
    {
        $data = $context->data;

        $entity = parent::_actionAdd($context);

        //if a person posting a message on his profile
        //or if a target is not actor then it can't be a private message
        if (get_viewer()->eql($this->actor) || !is_person($this->actor)) {
            unset($data->private);
        }

        //if a private message then
        //set the privacy to subject/target
        if ($data->private) {
            $entity->setAccess(array($this->actor->id, get_viewer()->id));
        }

        //create a notification for the subscribers and
        //the post owner as well
        if ($entity->owner->isSubscribable()) {
            //create a notification and pass the owner
            $notification = $this->createNotification(array(
                'name' => 'note_add',
                'object' => $entity,
                'subscribers' => array($entity->owner->subscriberIds->toArray(), $entity->owner),
            ))->setType('post', array('new_post' => true));
        }

        if (!empty($data['channels'])) {
            $this->shareObject(array(
                'object' => $entity,
                'sharers' => $data['channels']
            ));
        }

        return $entity;
    }
protected function _actionAdd ( $ context ) { $ data = $ context -> data ; $ entity = parent :: _actionAdd ( $ context ) ; //if a person posting a message on his profile //or if a target is not actor then it can't be a private message if ( get_viewer ( ) -> eql ( $ this -> actor ) || ! is_person ( $ this -> actor ) ) { unset ( $ data -> private ) ; } //if a private message then //set the privacy to subject/target if ( $ data -> private ) { $ entity -> setAccess ( array ( $ this -> actor -> id , get_viewer ( ) -> id ) ) ; } //create a notification for the subscribers and //the post owner as well if ( $ entity -> owner -> isSubscribable ( ) ) { //create a notification and pass the owner $ notification = $ this -> createNotification ( array ( 'name' => 'note_add' , 'object' => $ entity , 'subscribers' => array ( $ entity -> owner -> subscriberIds -> toArray ( ) , $ entity -> owner ) , ) ) -> setType ( 'post' , array ( 'new_post' => true ) ) ; } if ( ! empty ( $ data [ 'channels' ] ) ) { $ this -> shareObject ( array ( 'object' => $ entity , 'sharers' => $ data [ 'channels' ] ) ) ; } return $ entity ; }
Adds a new post.

@param AnCommandContext $context Context parameter
Adds a new post .