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


PHP Entity::get方法代码示例

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


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

示例1: __construct

 function __construct()
 {
     // find active entity
     $user = Authentication::require_user();
     $this->entity = Entity::get(@$_SERVER['PATH_INFO'], !$user->is_admin);
     // Redjudge all
     if (isset($_REQUEST['rejudge_all']) and Authentication::is_admin()) {
         Log::info("Requested redjudgement for all submissions in this entity", $this->entity->path());
         foreach ($this->entity->all_submissions() as $subm) {
             $subm->rejudge();
         }
         Util::redirect(str_replace('rejudge_all=1', '', $_SERVER['REQUEST_URI']));
     }
 }
开发者ID:jlsa,项目名称:justitia,代码行数:14,代码来源:PageWithEntity.php

示例2: getDuplicateWhereClause

 protected function getDuplicateWhereClause(Entity $entity)
 {
     return array('name' => $entity->get('name'));
 }
开发者ID:chinazan,项目名称:zzcrm,代码行数:4,代码来源:Agent.php

示例3: validateField

 public static function validateField(Entity $entity, $key)
 {
     $tag = "EntityValidator::validateField({$key})";
     Log::debug("{$tag}");
     try {
         $value = $entity->get($key);
         $blueprint = $entity->blueprint();
         $field = $blueprint->get($key);
         $displayName = $field->getDisplayName();
         $dataType = $field->getDataType();
         if ($field->isRequired()) {
             if (empty($value) && $value != "0") {
                 return "Missing required value '{$displayName}'";
             }
         }
         if (!empty($value) || $value == "0") {
             switch ($dataType) {
                 case "string":
                     $max = $field->getMax();
                     if (!empty($max) && strlen($value) > $max) {
                         return "'{$displayName}' exceeds maximum character limit ({$max})";
                     }
                     $regexp = $field->getRegexp();
                     if (!empty($regexp)) {
                         if (!ereg($regexp, $value)) {
                             $example = $field->getExample();
                             return "'{$displayName}' does not match the required pattern '{$example}'";
                         }
                     }
                     break;
                 case "int":
                     if (!is_numeric($value) || strpos($value, ".")) {
                         return "'{$displayName}' must be an integer";
                     }
                     $min = $field->getMin();
                     if ((!empty($min) || $min == "0") && $value < $min) {
                         return "'{$displayName}' less than minimum required ({$min})";
                     }
                     $max = $field->getMax();
                     if ((!empty($max) || $max == "0") && $value > $max) {
                         return "'{$displayName}' greater than maximum allowed ({$max})";
                     }
                     break;
                 case "decimal":
                     if (!is_numeric($value)) {
                         return "'{$displayName}' must be a number";
                     }
                     $min = $field->getMin();
                     if ((!empty($min) || $min == "0") && $value < $min) {
                         return "'{$displayName}' less than minimum required ({$min})";
                     }
                     $max = $field->getMax();
                     if ((!empty($max) || $max == "0") && $value > $max) {
                         return "'{$displayName}' greater than maximum allowed ({$max})";
                     }
                     $precision = $field->getPrecision();
                     if ($decimalPosition = strpos($value, ".")) {
                         $decimals = substr($value, $decimalPosition + 1);
                         if (!empty($precision) && strlen($decimals) > $precision) {
                             return "'{$displayName}' has more than {$precision} allowed digits after decimal point";
                         }
                     }
                     break;
                 case "date":
                     $regexp = "^([0-9]{4})\\-([0-9]{2})\\-([0-9]{2})\$";
                     $example = $field->getExample();
                     if (!ereg($regexp, $value, $regs)) {
                         return "'{$displayName}' does not match required pattern '{$example}'";
                     }
                     $year = $regs[1];
                     $month = $regs[2];
                     $day = $regs[3];
                     if (!checkdate($month, $day, $year)) {
                         return "'{$displayName}' is not a valid date";
                     }
                     break;
                 case "datetime":
                     $regexp = "^([0-9]{4})\\-([0-9]{2})\\-([0-9]{2}) ([0-9]{2})\\:([0-9]{2})\\:([0-9]{2})\$";
                     $example = $field->getExample();
                     if (!ereg($regexp, $value, $regs)) {
                         return "'{$displayName}' does not match required pattern '{$example}'";
                     }
                     $year = $regs[1];
                     $month = $regs[2];
                     $day = $regs[3];
                     $hour = $regs[4];
                     $minute = $regs[5];
                     $seconds = $regs[6];
                     if (!checkdate($month, $day, $year)) {
                         return "'{$displayName}' contains an valid date";
                     }
                     if ($hour > 23 || $minute > 59 || $seconds > 59) {
                         return "'{$displayName}' contains an invalid time";
                     }
                     break;
                 case "time":
                     $regexp = "^([0-9]{2})\\:([0-9]{2})(\\:([0-9]{2}))?\$";
                     $example = $field->getExample();
                     if (!ereg($regexp, $value, $regs)) {
                         return "'{$displayName}' does not match required pattern '{$example}'";
//.........这里部分代码省略.........
开发者ID:benjaminhough,项目名称:blueprints-web-kit,代码行数:101,代码来源:EntityValidator.php

示例4: insert

 public function insert(Entity $entity)
 {
     $tag = "EntityDAO: insert()";
     Log::notice("{$tag}");
     $blueprint = $this->blueprint;
     $timezone_offset = $this->timezone_offset_modify;
     $query = "INSERT INTO " . $this->tableName() . " SET ";
     if ($entity->getId() != 0) {
         $query .= "id=" . $entity->getId() . ", ";
     }
     foreach ($blueprint->fields() as $field) {
         $key = $field->getKey();
         $value = $entity->get($key);
         $encType = $field->getEncType();
         if (!empty($value) || $value == "0") {
             if (!empty($encType) && $encType != "plain") {
                 $value = hash($encType, $value);
                 Log::debug("{$tag}: Encrypted value for {$key}: {$value}");
             }
             switch ($field->getDataType()) {
                 case "int":
                     $query .= "{$key}={$value}";
                     break;
                 case "decimal":
                 case "date":
                     $query .= "{$key}='{$value}'";
                     break;
                 case "datetime":
                 case "time":
                     $query .= "{$key}=CONVERT_TZ('{$value}', '{$timezone_offset}', '" . BPTimezone::UTC . "')";
                     break;
                 case "enum":
                     $query .= "{$key}='{$value}'";
                     break;
                 case "string":
                 case "text":
                 case "binary":
                     $value = DatabaseSanitizer::sanitize($value);
                     $query .= "{$key}='{$value}'";
                     break;
             }
         } else {
             $query .= "{$key}=NULL";
         }
         $query .= ", ";
     }
     $query = substr($query, 0, strlen($query) - 2);
     // remove trailing comma and space (", ")
     $sql = new DatabaseUpdate($query, "insert");
     try {
         $sql->doUpdate();
         return $sql->last_insert_id();
     } catch (Exception $e) {
         Log::error("{$tag}: [" . $sql->err_code . "] " . $sql->err_message);
         throw $e;
     }
 }
开发者ID:benjaminhough,项目名称:blueprints-web-kit,代码行数:57,代码来源:EntityDAO.php

示例5: getDuplicateWhereClause

 protected function getDuplicateWhereClause(Entity $entity)
 {
     return array('OR' => array(array('firstName' => $entity->get('firstName'), 'lastName' => $entity->get('lastName')), array('emailAddress' => $entity->get('emailAddress'))));
 }
开发者ID:jdavis593,项目名称:appitechture,代码行数:4,代码来源:Lead.php

示例6: entity

 function entity()
 {
     // it is not a fetal error if the entity does not exist
     return Entity::get($this->entity_path, false, false);
 }
开发者ID:jlsa,项目名称:justitia,代码行数:5,代码来源:Submission.php

示例7: array

<?php

require_once '../lib/bootstrap.inc';
// -----------------------------------------------------------------------------
// Ajax utility: return newest submissions
// -----------------------------------------------------------------------------
if (Authentication::current_user() == false) {
    echo '{"logout":"true"}';
} else {
    if (Authentication::is_admin() and isset($_GET['entity']) and isset($_GET['submissionid'])) {
        try {
            // get entity
            $entity = Entity::get($_GET['entity'], false, true);
            $submissions = $entity->submissions_after($_GET['submissionid']);
            $arr = array();
            foreach ($submissions as $s) {
                $arr[] = $s->submissionid;
            }
            echo '{"new_ids":' . json_encode($arr) . '}';
        } catch (NotFoundException $e) {
            exit;
        }
    } else {
        die("You have no rights to view this submission");
    }
}
开发者ID:jlsa,项目名称:justitia,代码行数:26,代码来源:ajax_latestsubmissions.php

示例8: checkForErrors

 /**
  * Checks if a given entity or its children entities have errors.
  * If so, sets _hasErrors and returns true, if not, returns false.
  *
  * @param Entity $entity entity which has possibly errors in it
  * @return bool          has errors => true | has no errors => false
  */
 public function checkForErrors($entity)
 {
     if (is_callable([$entity, 'errors']) && !empty($entity->errors())) {
         return $this->hasErrors(true);
     }
     foreach ($entity->visibleProperties() as $propertyName) {
         $property = $entity->get($propertyName);
         if (is_callable([$property, 'errors']) && !empty($property->errors())) {
             return $this->hasErrors(true);
         }
     }
     return false;
 }
开发者ID:scherersoftware,项目名称:cake-api-baselayer,代码行数:20,代码来源:ApiComponent.php

示例9: testSetWithAccessibleWithArray

 /**
  * Tests that only accessible properties can be set
  *
  * @return void
  */
 public function testSetWithAccessibleWithArray()
 {
     $entity = new Entity(['foo' => 1, 'bar' => 2]);
     $options = ['guard' => true];
     $entity->accessible('foo', true);
     $entity->set(['bar' => 3, 'foo' => 4], $options);
     $this->assertEquals(2, $entity->get('bar'));
     $this->assertEquals(4, $entity->get('foo'));
     $entity->accessible('bar', true);
     $entity->set(['bar' => 3, 'foo' => 5], $options);
     $this->assertEquals(3, $entity->get('bar'));
     $this->assertEquals(5, $entity->get('foo'));
 }
开发者ID:josegonzalez,项目名称:cakephp-entity,代码行数:18,代码来源:EntityTest.php

示例10: tempnam

<?php

require_once '../lib/bootstrap.inc';
// -----------------------------------------------------------------------------
// Allow a user do download 'extra' files for an entity
// -----------------------------------------------------------------------------
$user = Authentication::require_user();
$entity = Entity::get(@$_SERVER['PATH_INFO'], !$user->is_admin);
// Which file are we downloading?
if (isset($_REQUEST['all'])) {
    // download all files as a zip archive
    $filepath = tempnam('', 'zip');
    $delete_temp_file = $filepath;
    $zip = new ZipArchive();
    $result = $zip->open($filepath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);
    if ($result !== true) {
        die("Failed to open zip file '{$filepath}', error code {$result}");
    }
    $files = $entity->downloadable_files();
    foreach ($files as $filename) {
        $zip->addFile($entity->data_path() . $filename, $filename);
    }
    $zip->close();
    $filename = $entity->dir_name() . '.zip';
    $filetype = 'application/zip';
} else {
    $filename = @$_REQUEST['f'];
    $files = $entity->downloadable_files();
    if (!in_array($filename, $files)) {
        die("You have no rights to view this file.");
    }
开发者ID:jlsa,项目名称:justitia,代码行数:31,代码来源:download_entity.php


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