コード例 #1
0
 /**
  * Checks that the given instance's slug do not collide with table's real column
  * names.
  *
  * If collision occurs, an error message will be registered on the given entity.
  *
  * @param \Field\Model\Entity\FieldInstance $instance Instance to validate
  * @return void
  */
 protected function _validateSlug($instance)
 {
     $slug = $instance->get('eav_attribute')->get('name');
     $columns = $this->_table->schema()->columns();
     if (in_array($slug, $columns)) {
         $instance->get('eav_attribute')->errors('name', __d('field', 'The name "{0}" cannot be used as it collides with table column names.', $slug));
     }
 }
コード例 #2
0
 /**
  * Triggers the callback "beforeDetach".
  *
  * @param \Cake\Event\Event $event The event that was triggered
  * @param \Field\Model\Entity\FieldInstance $instance The Field Instance that is going to be deleted
  * @param \ArrayObject $options the options passed to the delete method
  * @return bool False if delete operation should not continue, true otherwise
  */
 public function beforeDelete(Event $event, FieldInstance $instance, ArrayObject $options = null)
 {
     $result = $instance->beforeDetach();
     if ($result === false) {
         return false;
     }
     $this->_deleted = $this->get($instance->get('id'), ['contain' => ['EavAttribute']]);
     return true;
 }