本文整理匯總了PHP中Cake\Datasource\EntityInterface::source方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityInterface::source方法的具體用法?PHP EntityInterface::source怎麽用?PHP EntityInterface::source使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cake\Datasource\EntityInterface
的用法示例。
在下文中一共展示了EntityInterface::source方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: tagsChooser
/**
* Render a multi select with all available tags of entity and the tags of attachment preselected
*
* @param EntityInterface $entity the entity to get all allowed tags from
* @param Attachment\Model\Entity\Attachment $attachment the attachment entity to add the tag to
* @return string
*/
public function tagsChooser(EntityInterface $entity, $attachment)
{
if (!TableRegistry::exists($entity->source())) {
throw new Cake\Network\Exception\MissingTableException('Could not find Table ' . $entity->source());
}
$Table = TableRegistry::get($entity->source());
return $this->Form->select('tags', $Table->getAttachmentsTags(), ['type' => 'select', 'class' => 'tag-chooser', 'style' => 'display: block; width: 100%', 'label' => false, 'multiple' => true, 'value' => $attachment->tags]);
}
示例2: toggle
public function toggle(EntityInterface $entity)
{
$limit = $this->config('implementedServices.' . $entity->source())->config('limit');
if ($limit !== 1) {
throw new Exception(sprintf('Toggle disabled, type "%s" limit is "%s"', $entity->source(), $limit));
}
// if current user in $entity->reviewed_by
// if so goto unreview
// else goto review
}
示例3: _repository
/**
* Gets the repository for this entity
*
* @param EntityInterface $entity
* @return Table
*/
protected function _repository($entity)
{
$source = $entity->source();
if ($source === null) {
list(, $class) = namespaceSplit(get_class($entity));
$source = Inflector::pluralize($class);
}
return TableRegistry::get($source);
}
示例4: __getFileName
/**
* recursive method to increase the filename in case the file already exists
*
* @param string $fileInfo Array of information about the file
* @param EntityInterface $entity Entity
* @param string $id counter varibale to extend the filename
* @return array
*/
private function __getFileName($fileInfo, EntityInterface $entity, $id = 0)
{
if (!file_exists(Configure::read('Attachments.path') . $entity->source() . '/' . $entity->id . '/' . $fileInfo['basename'])) {
return $fileInfo;
}
$fileInfo['basename'] = $fileInfo['filename'] . ' (' . ++$id . ').' . $fileInfo['extension'];
return $this->__getFileName($fileInfo, $entity, $id);
}
示例5: _getTableAlias
/**
* Get table alias for the given entity.
*
* @param \Cake\Datasource\EntityInterface $entity The entity
* @return string Table alias
*/
protected function _getTableAlias(EntityInterface $entity)
{
$alias = $entity->source();
if (mb_strpos($alias, '.') !== false) {
$parts = explode('.', $alias);
$alias = array_pop($parts);
}
return strtolower($alias);
}
示例6: deleteButton
/**
* Renders an delete button
*
* @param EntityInterface $entity Entity to take the ID from
* @param array $options Config options
* @return string
*/
public function deleteButton(EntityInterface $entity, array $options = [])
{
$options = Hash::merge(['url' => null, 'title' => __d('cktools', 'delete'), 'icon' => 'fa fa-trash-o', 'class' => 'btn btn-danger btn-xs', 'confirm' => __d('cktools', 'delete_confirmation')], $options);
$url = $options['url'];
$title = $options['title'];
$icon = $options['icon'];
unset($options['url'], $options['title'], $options['icon']);
if (!$url) {
$url = ['controller' => $entity->source(), 'action' => 'delete', $entity->id];
}
if ($icon) {
$title = '<i class="' . $icon . '"></i> ' . '<span class="button-text">' . $title . '</span>';
$options['escape'] = false;
}
return $this->Html->link($title, $url, $options);
}
示例7: __invoke
public function __invoke(EntityInterface $row)
{
$primaryKey = array_values($row->extract((array) $this->table->primaryKey()));
$row->_links = ['self' => ['href' => Router::url(['controller' => $row->source(), 'action' => 'view'] + $primaryKey)]];
return $this->enrich($row);
}
示例8: deleteButton
/**
* Renders an delete button
*
* @param EntityInterface $entity Entity to take the ID from
* @param array $options Config options
* @return string
*/
public function deleteButton(EntityInterface $entity, array $options = [])
{
$options = Hash::merge(['url' => null, 'title' => __d('cktools', 'delete'), 'icon' => 'fa fa-trash-o', 'class' => 'btn btn-danger btn-xs', 'confirm' => __d('cktools', 'delete_confirmation'), 'usePostLink' => false], $options);
$url = $options['url'];
$title = $options['title'];
$icon = $options['icon'];
unset($options['url'], $options['title'], $options['icon']);
if (!$url) {
list($plugin, $controller) = pluginSplit($entity->source());
$url = ['plugin' => $this->_View->request->plugin, 'controller' => $controller, 'action' => 'delete', $entity->id];
}
if ($icon) {
$title = '<i class="' . $icon . '"></i> ' . '<span class="button-text">' . $title . '</span>';
$options['escape'] = false;
}
if ($options['usePostLink']) {
return $this->Form->postLink($title, $url, $options);
} else {
return $this->Html->link($title, $url, $options);
}
}