/**
  * 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));
     }
 }
 /**
  * Triggers the callback "afterDetach", it also deletes all associated records
  * in the "field_values" table.
  *
  * @param \Cake\Event\Event $event The event that was triggered
  * @param \Field\Model\Entity\FieldInstance $instance The Field Instance that was deleted
  * @param \ArrayObject $options the options passed to the delete method
  * @return void
  */
 public function afterDelete(Event $event, FieldInstance $instance, ArrayObject $options = null)
 {
     if (!empty($this->_deleted)) {
         TableRegistry::get('Eav.EavAttributes')->delete($this->_deleted->get('eav_attribute'));
         $instance->afterDetach();
         $this->_deleted = null;
     }
 }