original_string: public function setDefaults($type = false)
      {
          if (!$type) {
              if (!$this->has('content_type_slug') && !$this->has('id')) {
                  throw new FatalErrorException(__d('content', 'Unable to get Content-Type information.'));
              }
  
              if (!$this->has('content_type_slug')) {
                  $contentTypeSlug = TableRegistry::get('Content.Contents')->find()
                      ->select(['content_type_slug'])
                      ->where(['id' => $this->get('id')])
                      ->first();
                  $contentTypeSlug = $contentTypeSlug->content_type_slug;
              } else {
                  $contentTypeSlug = $this->get('content_type_slug');
              }
  
              $type = TableRegistry::get('Content.ContentTypes')->find()
                  ->where(['slug' => $contentTypeSlug])
                  ->first();
          }
  
          if (!($type instanceof ContentType) || !$type->has('defaults')) {
              throw new FatalErrorException(__d('content', "Content::setDefaults() was unable to get Content Type defaults values."));
          }
  
          $this->set('language', $type->defaults['language']);
          $this->set('comment_status', $type->defaults['comment_status']);
          $this->set('status', $type->defaults['status']);
          $this->set('promote', $type->defaults['promote']);
          $this->set('sticky', $type->defaults['sticky']);
      }
code: public function setDefaults($type = false)
      {
          if (!$type) {
              if (!$this->has('content_type_slug') && !$this->has('id')) {
                  throw new FatalErrorException(__d('content', 'Unable to get Content-Type information.'));
              }
  
              if (!$this->has('content_type_slug')) {
                  $contentTypeSlug = TableRegistry::get('Content.Contents')->find()
                      ->select(['content_type_slug'])
                      ->where(['id' => $this->get('id')])
                      ->first();
                  $contentTypeSlug = $contentTypeSlug->content_type_slug;
              } else {
                  $contentTypeSlug = $this->get('content_type_slug');
              }
  
              $type = TableRegistry::get('Content.ContentTypes')->find()
                  ->where(['slug' => $contentTypeSlug])
                  ->first();
          }
  
          if (!($type instanceof ContentType) || !$type->has('defaults')) {
              throw new FatalErrorException(__d('content', "Content::setDefaults() was unable to get Content Type defaults values."));
          }
  
          $this->set('language', $type->defaults['language']);
          $this->set('comment_status', $type->defaults['comment_status']);
          $this->set('status', $type->defaults['status']);
          $this->set('promote', $type->defaults['promote']);
          $this->set('sticky', $type->defaults['sticky']);
      }
code_tokens: public function setDefaults ( $ type = false ) { if ( ! $ type ) { if ( ! $ this -> has ( 'content_type_slug' ) && ! $ this -> has ( 'id' ) ) { throw new FatalErrorException ( __d ( 'content' , 'Unable to get Content-Type information.' ) ) ; } if ( ! $ this -> has ( 'content_type_slug' ) ) { $ contentTypeSlug = TableRegistry :: get ( 'Content.Contents' ) -> find ( ) -> select ( [ 'content_type_slug' ] ) -> where ( [ 'id' => $ this -> get ( 'id' ) ] ) -> first ( ) ; $ contentTypeSlug = $ contentTypeSlug -> content_type_slug ; } else { $ contentTypeSlug = $ this -> get ( 'content_type_slug' ) ; } $ type = TableRegistry :: get ( 'Content.ContentTypes' ) -> find ( ) -> where ( [ 'slug' => $ contentTypeSlug ] ) -> first ( ) ; } if ( ! ( $ type instanceof ContentType ) || ! $ type -> has ( 'defaults' ) ) { throw new FatalErrorException ( __d ( 'content' , "Content::setDefaults() was unable to get Content Type defaults values." ) ) ; } $ this -> set ( 'language' , $ type -> defaults [ 'language' ] ) ; $ this -> set ( 'comment_status' , $ type -> defaults [ 'comment_status' ] ) ; $ this -> set ( 'status' , $ type -> defaults [ 'status' ] ) ; $ this -> set ( 'promote' , $ type -> defaults [ 'promote' ] ) ; $ this -> set ( 'sticky' , $ type -> defaults [ 'sticky' ] ) ; }
docstring: Set defaults content settings based on parent content type.
  
  You can provide a ContentType entity to fetch defaults values. By default if
  none is provided it automatically fetches the information from the
  corresponding Content Type.
  
  @param bool|\Content\Model\Entity\ContentType $type False for auto fetch or a
  ContentType entity to extract information from
  @return void
  @throws Cake\Error\FatalErrorException When content type was not found for
  this content content.
docstring_tokens: Set defaults content settings based on parent content type .