Example #1
0
 public function getAttributeValueObject($ak, $createIfNotExists = false)
 {
     if (!is_object($ak)) {
         $ak = SiteKey::getByHandle($ak);
     }
     $value = false;
     if (is_object($ak)) {
         $value = $this->getObjectAttributeCategory()->getAttributeValue($ak, $this);
     }
     if ($value) {
         return $value;
     } elseif ($createIfNotExists) {
         $attributeValue = new SiteValue();
         $attributeValue->setSite($this);
         $attributeValue->setAttributeKey($ak);
         return $attributeValue;
     }
 }
Example #2
0
 public function update_sitename()
 {
     if ($this->token->validate("update_sitename")) {
         if ($this->isPost()) {
             $this->site->setSiteName($this->request->request->get('SITE'));
             $this->entityManager->persist($this->site);
             $this->entityManager->flush();
             $attributes = SiteKey::getList();
             foreach ($attributes as $ak) {
                 $controller = $ak->getController();
                 $value = $controller->createAttributeValueFromRequest();
                 $this->site->setAttribute($ak, $value);
             }
             $this->redirect('/dashboard/system/basics/name', 'sitename_saved');
         }
     } else {
         $this->set('error', array($this->token->getErrorMessage()));
     }
 }
Example #3
0
 public function delete(Site $site)
 {
     $attributes = SiteKey::getAttributeValues($site);
     foreach ($attributes as $av) {
         $this->entityManager->remove($av);
     }
     $this->entityManager->flush();
     $r = $this->entityManager->getConnection()->executeQuery('select cID from Pages where siteTreeID = ? and cParentID = 0', [$site->getSiteTreeID()]);
     while ($row = $r->fetch()) {
         $page = \Page::getByID($row['cID']);
         if (is_object($page) && !$page->isError()) {
             $page->moveToTrash();
         }
     }
     $this->entityManager->remove($site);
     $this->entityManager->flush();
 }
Example #4
0
 public function delete($akID = null)
 {
     $key = SiteKey::getByID($akID);
     $this->executeDelete($key, \URL::to('/dashboard/system/basics/attributes', 'view'));
 }