当前位置: 首页>>代码示例>>PHP>>正文


PHP Entity::source方法代码示例

本文整理汇总了PHP中Cake\ORM\Entity::source方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::source方法的具体用法?PHP Entity::source怎么用?PHP Entity::source使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\ORM\Entity的用法示例。


在下文中一共展示了Entity::source方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: url

 /**
  * Get uploaded image URL.
  * Return wrong URL if path config is not under webroot.
  * UrlHelper::build generates URL.
  *
  * @param \Cake\ORM\Entity $entity The entity
  * @param string $field The image field name
  * @return string
  */
 public function url(Entity $entity, $field)
 {
     $table = TableRegistry::get($entity->source());
     $folder = $table->getUploadFolder($entity, $field);
     $path = str_replace(WWW_ROOT, '', $folder);
     $path .= $entity->get($field);
     return $this->Url->build("/{$path}");
 }
开发者ID:dala00,项目名称:cakephp-simple-upload,代码行数:17,代码来源:UploadHelper.php

示例2: afterSave

 public function afterSave(Event $event, Entity $entity)
 {
     $model = substr(strrchr($entity->source(), '.'), 1);
     if (!$model) {
         $model = $entity->source();
     }
     $type_id = self::HISTORIES_CREATE;
     if (!$entity->isNew()) {
         $type_id = self::HISTORIES_UPDATE;
     }
     $user_id = 0;
     // Unknow
     debug($this->request->session()->read('Auth.User.id'));
     die;
     $this->Histories = TableRegistry::get('Histories');
     $history = $this->Histories->newEntity(['model' => $model, 'foreign_key' => $entity->id, 'type_id' => $type_id, 'user_id' => $user_id, 'created' => new Time()]);
     $this->Histories->save($history);
 }
开发者ID:Aerue,项目名称:avalia,代码行数:18,代码来源:HistoriesBehavior.php

示例3: nestedListFormat

 /**
  * Format nested list element
  * 
  * Callback method used by The NestableHelper
  *
  * @param array $data NestableHelper configuration
  * @param \Cake\ORM\Entity $entity Entity to format
  */
 public function nestedListFormat(array $data, Entity $entity)
 {
     $displayField = TableRegistry::get($entity->source())->displayField();
     $html = '<span class="pull-right p10 pb5">';
     $html .= $this->Html->link('<i class="fa fa-edit"></i> ', ['action' => 'edit', $entity->id], ['class' => '', 'escape' => false, 'title' => __d('admin', 'Edit')]);
     $html .= $this->Form->postLink('<i class="fa fa-trash-o"></i>', ['action' => 'delete', $entity['id']], ['class' => '', 'title' => __d('admin', 'Delete {0}', Inflector::humanize($entity->source)), 'escape' => false, 'confirm' => __d('admin', 'Are you sure you want to delete #{0} {1}?', $entity->id, $entity->{$displayField})]);
     $html .= '</span>';
     $html .= '<div class="dd-handle" data-id="' . $entity->id . '">';
     if ($entity->active === false) {
         $html .= '<span class="text-muted">' . $entity->{$displayField} . '</span>';
         $html .= ' <span class="text-danger"><i class="fa fa-ban"></i><em class="sr-only">Non active</em></span>';
     } else {
         $html .= $entity->{$displayField};
     }
     $html .= '</div>';
     return $html;
 }
开发者ID:orgasmicnightmare,项目名称:cakephp-absolute-admin-theme,代码行数:25,代码来源:AbsoluteAdminHelper.php

示例4: testTableFromEntitySource

 /**
  * Tests that the table can be derived from the entity source if it is present
  *
  * @return void
  */
 public function testTableFromEntitySource()
 {
     $entity = new Entity();
     $entity->source('Articles');
     $context = new EntityContext($this->request, ['entity' => $entity]);
     $expected = ['id', 'author_id', 'title', 'body', 'published'];
     $this->assertEquals($expected, $context->fieldNames());
 }
开发者ID:KarimaLadhani,项目名称:cakephp,代码行数:13,代码来源:EntityContextTest.php

示例5: testSource

 /**
  * Tests the source method
  *
  * @return void
  */
 public function testSource()
 {
     $entity = new Entity();
     $this->assertNull($entity->source());
     $entity->source('foos');
     $this->assertEquals('foos', $entity->source());
 }
开发者ID:jeremyheaton,项目名称:ultiswap,代码行数:12,代码来源:EntityTest.php

示例6: getUploadPath

 public function getUploadPath(Entity $entity, $path, $extension)
 {
     $replace = array('%uuid' => String::uuid(), '%id' => $entity->id, '%y' => date('Y'), '%m' => date('m'), '/' => DS);
     $path = $this->_config['assets_dir'] . DS . Inflector::tableize($entity->source()) . DS . strtr($path, $replace) . '.' . $extension;
     return $path;
 }
开发者ID:eripoll,项目名称:webiplan,代码行数:6,代码来源:UploaderBehavior.php

示例7: testIteratorAfterSerializationHydrated

 /**
  * Test iteration after serialization
  *
  * @return void
  */
 public function testIteratorAfterSerializationHydrated()
 {
     $query = $this->table->find('all');
     $results = unserialize(serialize($query->all()));
     // Use a loop to test Iterator implementation
     foreach ($results as $i => $row) {
         $expected = new \Cake\ORM\Entity($this->fixtureData[$i]);
         $expected->isNew(false);
         $expected->source($this->table->alias());
         $expected->clean();
         $this->assertEquals($expected, $row, "Row {$i} does not match");
     }
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:18,代码来源:ResultSetTest.php

示例8: path

 /**
  * Get the path formatted without its identifiers to upload the file.
  * @param \Cake\ORM\Entity $entity The entity that is going to be saved.
  * @param array $file The file array
  * @param string $path The path
  * @return string
  */
 private function path(Entity $entity, $file = [], $path = false)
 {
     // get extension & path
     $extension = (new File($file['name'], false))->ext();
     $path = trim(str_replace(['/', '\\'], DS, $path), DS);
     // handle identifiers
     $identifiers = [':model' => strtolower($entity->source()), ':md5' => md5(rand() . uniqid() . time())];
     // output
     return strtr($path, $identifiers) . '.' . strtolower($extension);
 }
开发者ID:unimatrix,项目名称:cakephp-utility,代码行数:17,代码来源:UploadableBehavior.php


注:本文中的Cake\ORM\Entity::source方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。