Inheritance: extends Gc\Core\Object
Esempio n. 1
0
 /**
  * Delete layout
  *
  * @return boolean
  */
 public function delete()
 {
     $this->events()->trigger(__CLASS__, 'before.delete', $this);
     $id = $this->getId();
     if (!empty($id)) {
         try {
             parent::delete(array('id' => $id));
         } catch (\Exception $e) {
             throw new \Gc\Exception($e->getMessage(), $e->getCode(), $e);
         }
         if (file_exists($this->getFilePath())) {
             unlink($this->getFilePath());
         }
         $this->events()->trigger(__CLASS__, 'after.delete', $this);
         unset($this);
         return true;
     }
     $this->events()->trigger(__CLASS__, 'after.delete.failed', $this);
     return false;
 }
Esempio n. 2
0
 /**
  * Load values
  *
  * @param AbstractTable $table Table
  *
  * @return AbstractForm
  */
 public function loadValues(AbstractTable $table)
 {
     $data = $table->getData();
     $inputFilter = $this->getInputFilter();
     if (is_array($data)) {
         foreach ($data as $elementName => $elementValue) {
             if ($this->has($elementName)) {
                 $this->get($elementName)->setValue($elementValue);
             }
             if ($inputFilter->has($elementName)) {
                 $validators = $inputFilter->get($elementName)->getValidatorChain()->getValidators();
                 foreach ($validators as $validator) {
                     if ($validator['instance'] instanceof NoRecordExists) {
                         $validator['instance']->setExclude(array('field' => 'id', 'value' => $table->getId()));
                     }
                 }
             }
         }
     }
     return $this;
 }
Esempio n. 3
0
 /**
  * Delete event
  *
  * @return boolean
  */
 public function delete()
 {
     $id = $this->getId();
     if (!empty($id)) {
         try {
             parent::delete(array('id' => $id));
         } catch (\Exception $e) {
             throw new \Gc\Exception($e->getMessage(), $e->getCode(), $e);
         }
         unset($this);
         return true;
     }
     return false;
 }
Esempio n. 4
0
 /**
  * Test
  *
  * @return void
  */
 public function testGetDriverName()
 {
     $this->assertInternalType('string', $this->object->getDriverName());
 }
Esempio n. 5
0
 /**
  * Delete tab
  *
  * @return boolean
  */
 public function delete()
 {
     $this->events()->trigger(__CLASS__, 'before.delete', $this);
     $tabId = $this->getId();
     if (!empty($tabId)) {
         try {
             $propertiesCollection = new Property\Collection();
             $propertiesCollection->load(null, $tabId);
             $propertiesCollection->delete();
             parent::delete(array('id' => $tabId));
         } catch (\Exception $e) {
             throw new \Gc\Exception($e->getMessage(), $e->getCode(), $e);
         }
         $this->events()->trigger(__CLASS__, 'after.delete', $this);
         unset($this);
         return true;
     }
     $this->events()->trigger(__CLASS__, 'after.delete.failed', $this);
     return false;
 }
Esempio n. 6
0
 /**
  * Delete document
  *
  * @return boolean
  */
 public function delete()
 {
     $this->events()->trigger(__CLASS__, 'before.delete', $this);
     $documentId = $this->getId();
     if (!empty($documentId)) {
         try {
             $propertiesTable = new TableGateway('property_value', $this->getAdapter());
             $propertiesTable->delete(array('document_id' => $this->getId()));
             parent::delete(array('id' => $documentId));
         } catch (\Exception $e) {
             throw new \Gc\Exception($e->getMessage(), $e->getCode(), $e);
         }
         $this->events()->trigger(__CLASS__, 'after.delete', $this);
         unset($this);
         return true;
     }
     $this->events()->trigger(__CLASS__, 'after.delete.failed', $this);
     return false;
 }
Esempio n. 7
0
 /**
  * Delete Role
  *
  * @return boolean
  */
 public function delete()
 {
     $this->events()->trigger(__CLASS__, 'before.delete', $this);
     $id = $this->getId();
     if (!empty($id)) {
         parent::delete(array('id' => $id));
         $this->events()->trigger(__CLASS__, 'after.delete', $this);
         unset($this);
         return true;
     }
     $this->events()->trigger(__CLASS__, 'after.delete.failed', $this);
     return false;
 }
Esempio n. 8
0
 /**
  * Delete property
  *
  * @return boolean
  */
 public function delete()
 {
     $this->events()->trigger(__CLASS__, 'before.delete', $this);
     $id = $this->getId();
     if (!empty($id)) {
         try {
             parent::delete(array('id' => (int) $id));
             $table = new TableGateway('property_value', $this->getAdapter());
             $table->delete(array('property_id' => (int) $id));
         } catch (\Exception $e) {
             throw new \Gc\Exception($e->getMessage());
         }
         $this->events()->trigger(__CLASS__, 'after.delete', $this);
         return true;
     }
     $this->events()->trigger(__CLASS__, 'after.delete.failed', $this);
     return false;
 }
Esempio n. 9
0
 /**
  * Delete document type model
  *
  * @return boolean
  */
 public function delete()
 {
     $this->events()->trigger(__CLASS__, 'before.delete', $this);
     $documentTypeId = $this->getId();
     if (!empty($documentTypeId)) {
         $tabCollection = new Tab\Collection();
         $tabCollection->load($documentTypeId);
         $tabCollection->delete();
         $table = new TableGateway('document_type_view', $this->getAdapter());
         $table->delete(array('document_type_id' => (int) $documentTypeId));
         parent::delete(array('id' => $documentTypeId));
         $this->events()->trigger(__CLASS__, 'after.delete', $this);
         unset($this);
         return true;
     }
     $this->events()->trigger(__CLASS__, 'after.delete.failed', $this);
     return false;
 }