예제 #1
0
 public function findPanelsAfter(PanelFacet $panel)
 {
     $dql = '
         SELECT pf
         FROM Claroline\\CoreBundle\\Entity\\Facet\\PanelFacet pf
         WHERE pf.facet = :facetId
         AND pf.position > :position
     ';
     $query = $this->_em->createQuery($dql);
     $query->setParameter('facetId', $panel->getFacet()->getId());
     $query->setParameter('position', $panel->getPosition());
     return $query->getResult();
 }
예제 #2
0
 /**
  * @param Facet $facet
  */
 public function setPanelFacet(PanelFacet $panelFacet)
 {
     $panelFacet->addFieldFacet($this);
     $this->panelFacet = $panelFacet;
 }
예제 #3
0
 /**
  * Order the fields of a panel according to the $ids order.
  *
  * @param array      $ids
  * @param PanelFacet $facet
  */
 public function orderFields(array $ids, PanelFacet $panel)
 {
     $fields = $panel->getFieldsFacet();
     foreach ($fields as $field) {
         foreach ($ids as $key => $id) {
             if ($id === $field->getId()) {
                 $field->setPosition($key);
                 $this->om->persist($field);
             }
         }
     }
     $this->om->flush();
 }
예제 #4
0
 public function checkPanelEdit(TokenInterface $token, PanelFacet $panel)
 {
     $userRoles = array_map(function ($el) {
         return $el->getRole();
     }, $token->getRoles());
     $panelRoles = $panel->getPanelFacetsRole();
     foreach ($panelRoles as $panelRole) {
         if (in_array($panelRole->getRole()->getName(), $userRoles)) {
             if ($panelRole->canEdit()) {
                 return VoterInterface::ACCESS_GRANTED;
             }
         }
     }
     return VoterInterface::ACCESS_DENIED;
 }
예제 #5
0
 public function setPanelFacet(PanelFacet $panelFacet)
 {
     $this->panelFacet = $panelFacet;
     $panelFacet->addPanelFacetRole($this);
 }
예제 #6
0
 public function setPanelEditable(PanelFacet $panel, $bool)
 {
     $panel->setIsEditable($bool);
     $this->om->persist($panel);
     $this->om->flush();
 }