Contao\FilesModel::findByPk PHP 메소드

findByPk() 공개 정적인 메소드

Find a file by its primary key
public static findByPk ( mixed $varValue, array $arrOptions = [] ) : FilesModel | null
$varValue mixed The value
$arrOptions array An optional options array
리턴 FilesModel | null The model or null if there is no file
    public static function findByPk($varValue, array $arrOptions = array())
    {
        if (static::$strPk == 'id') {
            return static::findById($varValue, $arrOptions);
        }
        return parent::findByPk($varValue, $arrOptions);
    }

Usage Example

 /**
  * Generate the content element
  */
 protected function compile()
 {
     if (($video = $this->getVideo()) === null) {
         return;
     }
     $video->setCustomName($this->vimeo_customName);
     $video->setPosterSize(deserialize($this->size, true));
     // Enable the lightbox
     if ($this->vimeo_lightbox) {
         $video->enableLightbox();
         // Enable the lightbox autoplay
         if ($this->vimeo_lightboxAutoplay) {
             $video->enableLightboxAutoplay();
         }
     }
     // Enable the link
     if ($this->vimeo_link) {
         $video->enableLink();
         $video->setLinkUrl($this->url);
         $video->setLinkTitle($this->titleText);
     }
     // Set a custom poster
     if ($this->vimeo_customPoster) {
         $fileModel = FilesModel::findByPk($this->singleSRC);
         if ($fileModel !== null && is_file(TL_ROOT . '/' . $fileModel->path)) {
             $video->setPoster($fileModel->path);
         }
     }
     $this->Template->buffer = $video->generate(new FrontendTemplate($this->vimeo_template));
 }
All Usage Examples Of Contao\FilesModel::findByPk