本文整理汇总了PHP中Entity::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Entity::getName方法的具体用法?PHP Entity::getName怎么用?PHP Entity::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: save
public function save(Entity $entity)
{
$data = array('name' => $entity->getName(), 'email' => $entity->getEmail(), 'phone' => $entity->getPhone(), 'message' => $entity->getMessage(), 'date' => $entity->getDate());
if ($entity->getId() > 0) {
$this->db->update($this->table, $data, $entity->getId());
} else {
$entity->setId($this->db->insert($this->table, $data));
}
}
示例3: save
public function save(Entity $entity)
{
$item = array('name' => $entity->getName(), 'address' => $entity->getAddress(), 'image' => $entity->getImage(), 'date_added' => $entity->getDateAdded());
if ($entity->getId() > 0) {
$this->update($item, array('id' => $entity->getId()));
} else {
$this->add($item);
}
}
示例4: save
public function save(Entity $entity)
{
$item = array('user_id' => $entity->getUserId(), 'name' => $entity->getName(), 'price' => $entity->getPrice(), 'quantity' => $entity->getQuantity(), 'image' => $entity->getImage(), 'date_added' => $entity->getDateAdded());
if ($entity->getId() > 0) {
$this->update($item, array('id' => $entity->getId()));
} else {
$this->add($item);
}
}
示例5: save
public function save(Entity $entity)
{
$data = array('product_id' => $entity->getProductId(), 'date' => $entity->getDate(), 'name' => $entity->getName(), 'email' => $entity->getEmail(), 'phone' => $entity->getPhone(), 'is_complete' => $entity->getIsComplete(), 'user_id' => $entity->getUserId());
if ($entity->getId() > 0) {
$this->db->update($this->table, $data, $entity->getId());
} else {
$entity->setId($this->db->insert($this->table, $data));
}
}
示例6: save
public function save(Entity $entity)
{
$data = array('name' => $entity->getName(), 'content' => $entity->getContent(), 'date' => date('Y-m-d H:i:s', strtotime($entity->getDate())), 'news_id' => $this->news_id);
if ($entity->getId() > 0) {
$this->db->update($this->table, $data, $entity->getId());
} else {
$entity->setId($this->db->insert($this->table, $data));
}
}
示例7: save
public function save(Entity $entity)
{
$dataInput = array('name' => $entity->getName(), 'image' => $entity->getImage(), 'category_id' => $entity->getCategoryId(), 'description' => $entity->getDescription());
if ($entity->getId() > 0) {
$this->update($entity->getId(), $dataInput);
} else {
$this->create($dataInput);
}
}
示例8: save
public function save(Entity $entity)
{
$item = array('product_id' => $entity->getProductId(), 'name' => $entity->getName(), 'image' => $entity->getImage(), 'is_cover' => $entity->getIsCover(), 'date_added' => $entity->getDateAdded());
if ($entity->getId() > 0) {
$this->update($item, array('id' => $entity->getId()));
} else {
$this->add($item);
}
}
示例9: generate
public function generate(Entity $entity)
{
$className = "{$entity->getName()}Service";
$destination = "src/impl/service/{$className}.php";
if (FileUtil::fileExists($destination)) {
return;
}
$content = "<?php\nclass {$className} extends {$className}Base {\n\n}\n?>";
FileUtil::storeFileContents($destination, $content);
}
示例10: getOppositeEntity
public function getOppositeEntity(Entity $entity)
{
if ($entity == $this->getOneEntity()) {
return $this->getOtherEntity();
} else {
if ($entity == $this->getOtherEntity()) {
return $this->getOneEntity();
} else {
throw new Exception("Entity '" . $entity->getName() . "' is related to neither '" . $this->getOneEntity()->getName() . "' nor '" . $this->getOtherEntity()->getName() . "'.");
}
}
}
示例11: generate
public function generate(Entity $entity)
{
$className = "{$entity->getName()}Model";
$content = "<?php\nabstract class {$className} extends Model {\n\n";
$content .= $this->gettersAndSetters($entity);
$content .= $this->getOneToManyGetters($entity);
$content .= $this->getOneToManyMappedGettersSetters($entity);
$content .= $this->getManyToManyGetters($entity);
$content .= "}\n?>";
// Write file to class
$destination = "src/service/model/{$className}.php";
FileUtil::storeFileContents($destination, $content);
}
示例12: generateCustomServices
private function generateCustomServices(Entity $entity)
{
$result = "";
$methods = ReflectionUtil::getSubclassMethods($entity->getName() . "Service");
foreach ($methods as $method) {
if (!$method->isPublic()) {
continue;
}
$name = $method->name;
$paramNames = array();
foreach ($method->getParameters() as $param) {
$paramNames[] = "\$" . $param->name;
}
$skeleton = $name . "(" . implode(", ", $paramNames) . ")";
$result .= "\tpublic static function {$skeleton} {\n" . "\t\treturn self::getService()->{$skeleton};\n" . "\t}\n\n";
}
return $result;
}
示例13: showForEntity
/**
* Show users of an entity
*
* @param $entity Entity object
**/
static function showForEntity(Entity $entity)
{
global $DB;
$ID = $entity->getField('id');
if (!$entity->can($ID, READ)) {
return false;
}
$canedit = $entity->canEdit($ID);
$canshowuser = User::canView();
$nb_per_line = 3;
$rand = mt_rand();
if ($canedit) {
$headerspan = $nb_per_line * 2;
} else {
$headerspan = $nb_per_line;
}
if ($canedit) {
echo "<div class='firstbloc'>";
echo "<form name='entityuser_form{$rand}' id='entityuser_form{$rand}' method='post' action='";
echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th colspan='6'>" . __('Add an authorization to a user') . "</tr>";
echo "<tr class='tab_bg_1'><td class='tab_bg_2 center'>" . __('User') . " ";
echo "<input type='hidden' name='entities_id' value='{$ID}'>";
User::dropdown(array('right' => 'all'));
echo "</td><td class='tab_bg_2 center'>" . self::getTypeName(1) . "</td><td>";
Profile::dropdownUnder(array('value' => Profile::getDefault()));
echo "</td><td class='tab_bg_2 center'>" . __('Recursive') . "</td><td>";
Dropdown::showYesNo("is_recursive", 0);
echo "</td><td class='tab_bg_2 center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
$query = "SELECT DISTINCT `glpi_profiles`.`id`, `glpi_profiles`.`name`\n FROM `glpi_profiles_users`\n LEFT JOIN `glpi_profiles`\n ON (`glpi_profiles_users`.`profiles_id` = `glpi_profiles`.`id`)\n LEFT JOIN `glpi_users` ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n WHERE `glpi_profiles_users`.`entities_id` = '{$ID}'\n AND `glpi_users`.`is_deleted` = '0'";
$result = $DB->query($query);
$nb = $DB->numrows($result);
echo "<div class='spaced'>";
if ($canedit && $nb) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('purge' => _x('button', 'Delete permanently')));
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
echo "<thead><tr>";
echo "<th class='noHover' colspan='{$headerspan}'>";
printf(__('%1$s (%2$s)'), _n('User', 'Users', Session::getPluralNumber()), __('D=Dynamic, R=Recursive'));
echo "</th></tr></thead>";
if ($nb) {
Session::initNavigateListItems('User', sprintf(__('%1$s = %2$s'), Entity::getTypeName(1), $entity->getName()));
while ($data = $DB->fetch_assoc($result)) {
echo "<tbody><tr class='noHover'>";
$reduce_header = 0;
if ($canedit && $nb) {
echo "<th width='10'>";
echo Html::checkAllAsCheckbox("profile" . $data['id'] . "_{$rand}");
echo "</th>";
$reduce_header++;
}
echo "<th colspan='" . ($headerspan - $reduce_header) . "'>";
printf(__('%1$s: %2$s'), __('Profile'), $data["name"]);
echo "</th></tr></tbody>";
echo "<tbody id='profile" . $data['id'] . "_{$rand}'>";
$query = "SELECT `glpi_users`.*,\n `glpi_profiles_users`.`id` AS linkID,\n `glpi_profiles_users`.`is_recursive`,\n `glpi_profiles_users`.`is_dynamic`\n FROM `glpi_profiles_users`\n LEFT JOIN `glpi_users`\n ON (`glpi_users`.`id` = `glpi_profiles_users`.`users_id`)\n WHERE `glpi_profiles_users`.`entities_id` = '{$ID}'\n AND `glpi_users`.`is_deleted` = '0'\n AND `glpi_profiles_users`.`profiles_id` = '" . $data['id'] . "'\n ORDER BY `glpi_profiles_users`.`profiles_id`,\n `glpi_users`.`name`,\n `glpi_users`.`realname`,\n `glpi_users`.`firstname`";
$result2 = $DB->query($query);
if ($DB->numrows($result2) > 0) {
$i = 0;
while ($data2 = $DB->fetch_assoc($result2)) {
Session::addToNavigateListItems('User', $data2["id"]);
if ($i % $nb_per_line == 0) {
if ($i != 0) {
echo "</tr>";
}
echo "<tr class='tab_bg_1'>";
}
if ($canedit) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data2["linkID"]);
echo "</td>";
}
$username = formatUserName($data2["id"], $data2["name"], $data2["realname"], $data2["firstname"], $canshowuser);
if ($data2["is_dynamic"] || $data2["is_recursive"]) {
$username = sprintf(__('%1$s %2$s'), $username, "<span class='b'>(");
if ($data2["is_dynamic"]) {
$username = sprintf(__('%1$s%2$s'), $username, __('D'));
}
if ($data2["is_dynamic"] && $data2["is_recursive"]) {
$username = sprintf(__('%1$s%2$s'), $username, ", ");
}
if ($data2["is_recursive"]) {
$username = sprintf(__('%1$s%2$s'), $username, __('R'));
}
$username = sprintf(__('%1$s%2$s'), $username, ")</span>");
//.........这里部分代码省略.........
示例14: getObjectProperty
/**
* Fetches a single property of the given object and returns its plain, unformatted value.
*
* @param Entity $entity
* @param type $id
* @param type $propertyName
* @param array $params
* @return property value or NULL if not present
*/
public function getObjectProperty(Entity $entity, $id, $propertyName, array $params)
{
$queryContext = new QueryContext($params, $entity);
// Always include blobs
$query = new QueryEntity($entity, $queryContext, Scope::parseValue(Scope::VALUE_P_ALL), $id);
$query->setPropertyNames(array($propertyName));
$mySQLi = $this->schema->getMySQLi();
$queryString = $query->getQueryString();
$queryResult = $mySQLi->query($queryString);
if (!$queryResult) {
throw new Exception("Error fetching property '{$propertyName}' of '" . $entity->getName() . "' - " . $mySQLi->error . "\n<!--\n{$queryString}\n-->");
}
$queryData = $queryResult->fetch_assoc();
$output = NULL;
if ($queryData) {
$output = $queryData[$propertyName];
}
$queryResult->close();
return $output;
}
示例15: getScope
public function getScope(Entity $entity, Scope $defaultScope)
{
if (array_key_exists($entity->getName(), $this->scopeMap)) {
return $this->scopeMap[$entity->getName()];
} else {
return $defaultScope;
}
}