本文整理汇总了PHP中Entity类的典型用法代码示例。如果您正苦于以下问题:PHP Entity类的具体用法?PHP Entity怎么用?PHP Entity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Entity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: post2
/**
* send a message to specified fluentd.
*
* @todo use HTTP1.1 protocol and persistent socket.
* @param string $tag
* @param array $data
*/
public function post2(Entity $entity)
{
$packed = json_encode($entity->getData());
$request = sprintf('http://%s:%d/%s?json=%s', $this->host, $this->port, $entity->getTag(), urlencode($packed));
$ret = file_get_contents($request);
return $ret !== false;
}
开发者ID:nagyist,项目名称:fluent-logger-php,代码行数:14,代码来源:HttpLogger.php
示例2: GetKids
function GetKids()
{
$entity = new Entity();
$query = "SELECT * FROM #__categories WHERE parent = ? ORDER BY ordering";
$objects = $entity->Collection($query, $this->id, __CLASS__);
return $objects;
}
开发者ID:beingsane,项目名称:Joomla--DAO,代码行数:7,代码来源:category.class.php
示例3: itemsToArray
/**
* Преобразование ветки объектов в структуру из массивов для вывода в шаблоне
* @param array $items Масив объектов - пунктов меню
* @param Entity $active Активный пункт меню
* @param bool $sub_active Признак, есть или нет активные подчиненные?
* @return array
*/
protected function itemsToArray($items, $active, &$sub_active = false)
{
$list = array();
$have_active = false;
foreach ($items as $item) {
$children = $item['sub'];
$item = $item['object'];
$real = $item->linked();
$info = array('title' => $item->title->value(), 'icon' => false, 'url' => Request::url($real->uri()), 'active' => $active && $active->eq($real) ? 1 : 0);
// Иконка
// $icon = $item->icon->isExist() ? $item->icon : ($real->icon->isExist()? $real->icon : null);
// if ($icon && !$icon->isDraft() && !$icon->isHidden()){
// $info['icon'] = $icon->resize(0,30,Image::FIT_OUTSIDE_LEFT_TOP)->file();
// }
// Если заголовок не определен
if (empty($info['title'])) {
$info['title'] = $real->title->value();
if (empty($info['title'])) {
$info['title'] = $real->name();
}
}
if ($children) {
$info['children'] = $this->itemsToArray($children, $active, $sub_active);
if (!$info['active'] && $sub_active) {
$info['active'] = 2;
}
}
$have_active = $have_active || $info['active'];
$list[] = $info;
}
$sub_active = $have_active;
return $list;
}
开发者ID:boolive,项目名称:basic,代码行数:40,代码来源:menu.php
示例4: testInit
public function testInit()
{
$entity = new Entity();
$entity->name = 'myname';
$entity->loginname = 'test';
$entity->save();
}
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:7,代码来源:576TestCase.php
示例5: can_upload
function can_upload($session)
{
if ($session['authenticator']) {
$auth = $session['authenticator'];
$reason_session =& get_reason_session();
$username = $reason_session->get("username");
if (isset($_REQUEST['user_id']) && !empty($_REQUEST['user_id'])) {
$username = $reason_session->get('username');
$param_cleanup_rules = array('user_id' => array('function' => 'turn_into_int', 'extra_args' => array('zero_to_null' => 'true')));
$cleanRequest = array_merge($_REQUEST, carl_clean_vars($_REQUEST, $param_cleanup_rules));
$nametag = $cleanRequest['user_id'];
$id = get_user_id($username);
if (reason_user_has_privs($id, 'pose_as_other_user')) {
$user = new Entity($nametag);
$username = $user->get_value("name");
}
}
if ($auth['file']) {
require_once $auth['file'];
}
$args = array_merge(array($username), $auth['arguments']);
if (!call_user_func_array($auth['callback'], $args)) {
return false;
}
}
return true;
}
开发者ID:hunter2814,项目名称:reason_package,代码行数:27,代码来源:common.inc.php
示例6: testInitJoinTableSelfReferencingInsertingData
public function testInitJoinTableSelfReferencingInsertingData()
{
$e = new Entity();
$e->name = "Entity test";
$this->assertTrue($e->Entity[0] instanceof Entity);
$this->assertTrue($e->Entity[1] instanceof Entity);
$this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_TCLEAN);
$this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_TCLEAN);
$e->Entity[0]->name = 'Friend 1';
$e->Entity[1]->name = 'Friend 2';
$e->Entity[0]->Entity[0]->name = 'Friend 1 1';
$e->Entity[0]->Entity[1]->name = 'Friend 1 2';
$e->Entity[1]->Entity[0]->name = 'Friend 2 1';
$e->Entity[1]->Entity[1]->name = 'Friend 2 2';
$this->assertEqual($e->Entity[0]->name, 'Friend 1');
$this->assertEqual($e->Entity[1]->name, 'Friend 2');
$this->assertEqual($e->Entity[0]->Entity[0]->name, 'Friend 1 1');
$this->assertEqual($e->Entity[0]->Entity[1]->name, 'Friend 1 2');
$this->assertEqual($e->Entity[1]->Entity[0]->name, 'Friend 2 1');
$this->assertEqual($e->Entity[1]->Entity[1]->name, 'Friend 2 2');
$this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_TDIRTY);
$this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_TDIRTY);
$count = count($this->conn);
$e->save();
$this->assertEqual($count + 13, $this->conn->count());
}
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:26,代码来源:NestTestCase.php
示例7: save
public function save(Entity $entity)
{
$users = $this->db->get_all('users');
foreach ($users['data'] as $key => $value) {
$this->db->insert($this->table, array('msg' => $entity->getMessage(), 'is_read' => 0, 'user_id' => $value['id'], 'sender_id' => $this->user_id, 'recepient_id' => $value['id'], 'date_added' => $entity->getDate()));
}
}
开发者ID:rashidyusmen,项目名称:myproject,代码行数:7,代码来源:messages.php
示例8: generateNoSuchModelException
private function generateNoSuchModelException(Entity $entity)
{
$className = "NoSuch{$entity->getName()}Exception";
$content = "<?php\nclass {$className} extends Exception {\n\n}\n?>";
$destination = "src/exceptions/{$className}.php";
FileUtil::storeFileContents($destination, $content);
}
开发者ID:aeberh,项目名称:php-movico,代码行数:7,代码来源:ExceptionGenerator.php
示例9: onEntitySave
public function onEntitySave(Entity $entity)
{
//save to entity name only if doesn't exist
if (!$entity->rawGet('name')) {
$entity->setEntityField('name', $this->getFullName(false));
}
}
开发者ID:silky,项目名称:littlesis,代码行数:7,代码来源:Person.class.php
示例10: compareFkDependency
/**
* Compares two entities A and B. If A contains a foreign key referring to B, then A > B. So when sorting a list of
* entities this way, the entities will be sorted in creation order. (In this case B < A, because B must be created
* before A.)
*
* @param Entity $entityA
* @param Entity $entityB
* @return int compare
*/
public static function compareFkDependency(Entity $entityA, Entity $entityB)
{
if ($entityA == $entityB) {
return 0;
}
// Check if A has a foreign key that (directly or indirectly) refers to B.
$levelAtoB = $entityA->contaisFkReferringTo($entityB);
// Check if B has a foreign key that (directly or indirectly) refers to A.
$levelBtoA = $entityB->contaisFkReferringTo($entityA);
if ($levelAtoB < 0) {
// A does not contain a reference to B.
if ($levelBtoA < 0) {
// B does not contain a reference to A either, so A and B are not related.
return 0;
} else {
// B contains a reference to A, so B < A.
return -1;
}
} else {
// A contains a reference to B...
if ($levelBtoA < 0) {
// ...and B does not contain a reference to A, so A < B.
return 1;
} else {
// ...and B contains a reference to A too. The strongest wins!
return $levelAtoB < $levelBtoA ? 1 : -1;
}
}
}
开发者ID:RobBosman,项目名称:bransom.RestServer-PHP,代码行数:38,代码来源:ObjectEntity.class.php
示例11: process
public static function process(Entity $entity, $maxDepth = 10)
{
if ($maxDepth <= 0) {
$mapper = $entity->_getMapper();
$primaryKey = $mapper->getPrimaryKey($mapper->getTable(get_class($entity)));
return isset($primaryKey) && isset($entity->{$primaryKey}) ? $entity->{$primaryKey} : null;
}
$data = [];
foreach ($entity->getData() as $name => $value) {
if (is_array($value)) {
$items = [];
foreach ($value as $item) {
$items[] = self::process($item, $maxDepth - 1);
}
$value = $items;
} elseif (is_object($value) && !is_null($value)) {
if ($value instanceof \DateTime) {
$value = $value->format('Y-m-d H:i:s');
} elseif ($value instanceof Entity) {
$value = self::process($value, $maxDepth - 1);
}
}
$data[$name] = $value;
}
return $data;
}
开发者ID:tharos,项目名称:leanmapper,代码行数:26,代码来源:EntityDataDecoder.php
示例12: processRow
public function processRow($row)
{
$arr = str_getcsv($row);
$ticker = $arr[0];
$name = $arr[1];
$name = str_replace(''', "'", $name);
if ($name == 'Name') {
return false;
}
$cap = $arr[3];
if ($cap < $this->min_market_cap) {
$this->too_small_ct++;
return false;
} else {
$corp = Doctrine::getTable('PublicCompany')->findOneByTicker($ticker);
if ($corp) {
$this->existing_ct++;
return false;
} else {
$corp = new Entity();
$corp->addExtension('Org');
$corp->addExtension('Business');
$corp->addExtension('PublicCompany');
$corp->ticker = $ticker;
$corp->name = $name;
$corp->save();
$this->printDebug("New company added: " . $name);
$this->added_ct++;
}
}
}
开发者ID:silky,项目名称:littlesis,代码行数:31,代码来源:TickerScraper.class.php
示例13: swap
/**
* Swaps field values of two objects
*
* @param Entity $object1
* @param Entity $object2
* @param string $field name of the field to be swapped
*/
public function swap(Entity $object1, Entity $object2, $field)
{
$old_field = $object1[$field];
$object1[$field] = $object2[$field];
$object2[$field] = $old_field;
$object1->store();
$object2->store();
}
开发者ID:nicksp,项目名称:BakedCarrot,代码行数:15,代码来源:Collection.php
示例14: update
/**
* @param \PHPSC\Conference\Infra\Persistence\Entity $obj
*/
public function update(Entity $obj)
{
if ($obj->getId() == 0) {
throw new EntityDoesNotExistsException('Não é possível atualizar uma entidade que ainda não foi adicionada');
}
$this->getEntityManager()->persist($obj);
$this->getEntityManager()->flush();
}
开发者ID:scdevsummit,项目名称:phpsc-conf,代码行数:11,代码来源:EntityRepository.php
示例15: generateIndexes
private function generateIndexes(Entity $entity)
{
$indexes = array("\tPRIMARY KEY (`{$entity->getPrimaryKey()->getName()}`)");
foreach ($entity->getFinders() as $finder) {
$indexes[] = "\t" . $finder->getIndexDefinition();
}
return $indexes;
}
开发者ID:aeberh,项目名称:php-movico,代码行数:8,代码来源:SqlGenerator.php
示例16: setUp
protected function setUp() {
global $DB;
$DB->connect();
// Store Max(id) for each glpi tables
$result = $DB->list_tables();
while ($data=$DB->fetch_row($result)) {
$query = "SELECT MAX(`id`) AS MAXID
FROM `".$data[0]."`";
foreach ($DB->request($query) as $row) {
$this->tables[$data[0]] = (empty($row['MAXID']) ? 0 : $row['MAXID']);
}
}
$DB->free_result($result);
$tab = array();
$auth = new Auth();
// First session
$auth->Login('glpi', 'glpi') ;
// Create entity tree
$entity = new Entity();
$tab['entity'][0] = $entity->add(array('name' => 'PHP Unit root',
'entities_id' => 0));
if (!$tab['entity'][0] // Crash detection
|| !FieldExists('glpi_profiles','notification') // Schema detection
|| countElementsInTable('glpi_rules')!=6) { // Old rules
if (!$tab['entity'][0]) {
echo "Couldn't run test (previous run not cleaned)\n";
} else {
echo "Schema need to be updated\n";
}
echo "Loading a fresh empty database:";
$DB->runFile(GLPI_ROOT ."/install/mysql/glpi-0.84-empty.sql");
die(" done\nTry again\n");
}
$tab['entity'][1] = $entity->add(array('name' => 'PHP Unit Child 1',
'entities_id' => $tab['entity'][0]));
$tab['entity'][2] = $entity->add(array('name' => 'PHP Unit Child 2',
'entities_id' => $tab['entity'][0]));
$tab['entity'][3] = $entity->add(array('name' => 'PHP Unit Child 2.1',
'entities_id' => $tab['entity'][2]));
$tab['entity'][4] = $entity->add(array('name' => 'PHP Unit Child 2.2',
'entities_id' => $tab['entity'][2]));
// New session with all the entities
$auth->Login('glpi', 'glpi') or die("Login glpi/glpi invalid !\n");
// Shared this with all tests
$this->sharedFixture = $tab;
}
开发者ID:KaneoGmbH,项目名称:glpi,代码行数:58,代码来源:AllTests.php
示例17: save
public function save(Entity $entity)
{
$dataInput = array('image' => $entity->getImage(), 'tours_id' => $entity->getToursId());
if ($entity->getId() > 0) {
$this->update($entity->getId(), $dataInput);
} else {
$this->create($dataInput);
}
}
开发者ID:dbcdeathdreamer,项目名称:SoftAcad,代码行数:9,代码来源:ToursImagesCollection.php
示例18: save
public function save(Entity $entity)
{
$item = array('title' => $entity->getTitle(), 'url' => $entity->getUrl());
if ($entity->getId() > 0) {
$this->update($item, array('id' => $entity->getId()));
} else {
$this->add($item);
}
}
开发者ID:AnyB1s,项目名称:softacad2015,代码行数:9,代码来源:Menu.php
示例19: save
protected function save(Entity $entity)
{
if ($entity->isNew()) {
$this->add($entity);
} else {
$this->update($entity);
}
return $this->pdo->lastInsertId();
}
开发者ID:snigle,项目名称:SimpleSecuredFrameworkPHP,代码行数:9,代码来源:Manager.class.php
示例20: postImpl
/**
* @param Entity $entity
* @return int
*/
protected function postImpl(Entity $entity)
{
/*
* example ouputs:
* 2012-02-26T01:26:20+0900 debug.test {"hello":"world"}
*/
$format = "%s\t%s\t%s\n";
return $this->write(sprintf($format, date(\DateTime::ISO8601, $entity->getTime()), $entity->getTag(), json_encode($entity->getData())));
}
开发者ID:cy-katsuhiro-miura,项目名称:fuelphp-with-fluentd,代码行数:13,代码来源:ConsoleLogger.php
注:本文中的Entity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论