protected function _ensureStatus(Entity $entity)
    {
        if (!$entity->has('status')) {
            return;
        }

        if (!$entity->has('content_type') &&
            ($entity->has('content_type_id') || $entity->has('content_type_slug'))
        ) {
            if ($entity->has('content_type_id')) {
                $type = $this->ContentTypes->get($entity->get('content_type_id'));
            } else {
                $type = $this->ContentTypes
                    ->find()
                    ->where(['content_type_slug' => $entity->get('content_type_id')])
                    ->limit(1)
                    ->first();
            }
        } else {
            $type = $entity->get('content_type');
        }

        if ($type && !$type->userAllowed('publish')) {
            if ($entity->isNew()) {
                $entity->set('status', false);
            } else {
                $entity->unsetProperty('status');
            }
        }
    }
protected function _ensureStatus(Entity $entity)
    {
        if (!$entity->has('status')) {
            return;
        }

        if (!$entity->has('content_type') &&
            ($entity->has('content_type_id') || $entity->has('content_type_slug'))
        ) {
            if ($entity->has('content_type_id')) {
                $type = $this->ContentTypes->get($entity->get('content_type_id'));
            } else {
                $type = $this->ContentTypes
                    ->find()
                    ->where(['content_type_slug' => $entity->get('content_type_id')])
                    ->limit(1)
                    ->first();
            }
        } else {
            $type = $entity->get('content_type');
        }

        if ($type && !$type->userAllowed('publish')) {
            if ($entity->isNew()) {
                $entity->set('status', false);
            } else {
                $entity->unsetProperty('status');
            }
        }
    }
protected function _ensureStatus ( Entity $ entity ) { if ( ! $ entity -> has ( 'status' ) ) { return ; } if ( ! $ entity -> has ( 'content_type' ) && ( $ entity -> has ( 'content_type_id' ) || $ entity -> has ( 'content_type_slug' ) ) ) { if ( $ entity -> has ( 'content_type_id' ) ) { $ type = $ this -> ContentTypes -> get ( $ entity -> get ( 'content_type_id' ) ) ; } else { $ type = $ this -> ContentTypes -> find ( ) -> where ( [ 'content_type_slug' => $ entity -> get ( 'content_type_id' ) ] ) -> limit ( 1 ) -> first ( ) ; } } else { $ type = $ entity -> get ( 'content_type' ) ; } if ( $ type && ! $ type -> userAllowed ( 'publish' ) ) { if ( $ entity -> isNew ( ) ) { $ entity -> set ( 'status' , false ) ; } else { $ entity -> unsetProperty ( 'status' ) ; } } }
Ensures that content content has the correct publishing status based in content
type restrictions.

If it's a new content it will set the correct status. However if it's an
existing content and user has no publishing permissions this method will not
change content's status, so it will remain published if it was already
published by an administrator.

@param \Cake\ORM\Entity $entity The content
@return void
Ensures that content content has the correct publishing status based in content type restrictions .