Gc\Document\Model::canBeCached PHP 메소드

canBeCached() 공개 메소드

Define if document can be cached
public canBeCached ( boolean $canBeCached = null ) : boolean
$canBeCached boolean Optional
리턴 boolean
    public function canBeCached($canBeCached = null)
    {
        if ($canBeCached !== null) {
            $this->setData('can_be_cached', $canBeCached);
        }
        return (bool) $this->getData('can_be_cached');
    }

Usage Example

예제 #1
0
 /**
  * Load document form from DocumentModel
  *
  * @param DocumentModel $document Document model
  * @param array         $config   Configuration
  *
  * @return void
  */
 public function load(DocumentModel $document, array $config)
 {
     $this->get('document-name')->setValue($document->getName());
     $this->get('document-url_key')->setValue($document->getUrlKey());
     $status = new Element\Checkbox('document-status');
     $status->setLabel('Publish')->setValue($document->isPublished())->setAttribute('id', 'status')->setAttribute('class', 'input-checkbox')->setCheckedValue((string) DocumentModel::STATUS_ENABLE);
     $this->add($status);
     $showInNav = new Element\Checkbox('document-show_in_nav');
     $showInNav->setLabel('Show in nav')->setValue($document->showInNav())->setAttribute('id', 'show_in_nav')->setAttribute('class', 'input-checkbox')->setCheckedValue((string) DocumentModel::STATUS_ENABLE);
     $this->add($showInNav);
     $canBeCached = new Element\Checkbox('document-can_be_cached');
     $canBeCached->setLabel('Can be cached')->setValue($document->canBeCached())->setAttribute('id', 'can_be_cached')->setAttribute('class', 'input-checkbox')->setCheckedValue((string) DocumentModel::STATUS_ENABLE);
     $this->add($canBeCached);
     array_unshift($config['locales'], '-- Use parent configuration');
     $locale = new Element\Select('document-locale');
     $locale->setLabel('Locale')->setValueOptions($config['locales'])->setValue($document->getLocale())->setAttribute('id', 'locale')->setAttribute('class', 'form-control');
     $this->add($locale);
     $documentType = $document->getDocumentType();
     $viewsCollection = $documentType->getAvailableViews();
     $select = $viewsCollection->getSelect();
     $viewSelected = $document->getViewId();
     $viewModel = View\Model::fromId($document->getDocumentType()->getDefaultViewId());
     if (!empty($viewModel)) {
         $select = $select + array($viewModel->getId() => $viewModel->getName());
         if (empty($viewSelected)) {
             $viewSelected = $viewModel->getId();
         }
     }
     $view = new Element\Select('document-view');
     $view->setValueOptions($select)->setValue((string) $viewSelected)->setAttribute('id', 'view')->setAttribute('class', 'form-control')->setLabel('View');
     $inputFilterFactory = $this->getInputFilter();
     $inputFilterFactory->add(array('name' => 'document-view', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'document-view');
     $this->add($view);
     $layoutsCollection = new Layout\Collection();
     $layout = new Element\Select('document-layout');
     $layout->setValueOptions($layoutsCollection->getSelect())->setValue((string) $document->getLayoutId())->setAttribute('id', 'layout')->setAttribute('class', 'form-control')->setLabel('Layout');
     $inputFilterFactory->add(array('name' => 'document-layout', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'document-layout');
     $this->add($layout);
     $this->remove('document_type');
     $this->remove('parent');
     $moreInformation = new Element\Hidden('more_information');
     $moreInformation->setAttribute('content', '');
     $this->add($moreInformation);
     $this->parentId = $document->getParentId();
     $this->documentId = $document->getId();
     $this->loadValues($document);
 }