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


PHP Type类代码示例

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


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

示例1: beforeDelete

 function beforeDelete($cascade)
 {
     // Remove the extended data to be tidy.
     // First get the type id
     App::Import('Model', 'Type');
     $Type = new Type();
     $Type->recursive = -1;
     $type_record = Set::extract('/Type/id', $Type->find('first', array('fields' => array('Type.id'), 'conditions' => array('Type.alias' => $this->model->data['Node']['type']))));
     $type_id = $type_record[0];
     // Cool, now find all node schemas
     App::Import('Model', 'NodeSchema.NodeSchema');
     $NodeSchema = new NodeSchema();
     $NodeSchema->actsAs = array('Containable');
     $schemas = $NodeSchema->find('all', array('fields' => array('NodeSchema.table_name'), 'contains' => array('Type' => array('conditions' => array('Type.id' => $type_id)))));
     // Now loop through and check for records on those tables to remove
     if (is_array($schemas) && count($schemas) > 0) {
         foreach ($schemas as $schema) {
             $table_name = $schema['NodeSchema']['table_name'];
             $model = new Model(false, $table_name);
             $model->primaryKey = 'node_id';
             // set the primary key to the node_id
             if ($model->delete($this->model->data['Node']['id'], false)) {
                 return true;
             } else {
                 // return false; // There was some sort of error deleting the associated data. Do we even need this? It doesn't redirect, it stops. Have to handle the error.
             }
         }
     }
     return true;
 }
开发者ID:hgassen,项目名称:node_schema,代码行数:30,代码来源:node_schema.php

示例2: manageTypes

 function manageTypes()
 {
     // Delete types in bulk
     if ($_POST['action'] == 'delete' && count($_POST['type_check']) > 0) {
         if ($this->delete('type')) {
             $this->showListTypes("Portfolio types successfully deleted");
             return;
         }
     }
     // if (isset($_POST['delete_type']) | isset($_POST['delete_entry'])) { }
     // If an individual type is specified, edit it (and/or validate and process it)
     // Otherwise, just show the full list of types
     if (empty($_GET['type'])) {
         $this->showListTypes();
     } else {
         $typeID = intval($_GET['type']);
         if (isset($_POST['submit_check'])) {
             // If the form was submitted...
             $type = new Type($_POST);
             if ($form_errors = $type->validate()) {
                 $this->editIndividualType($typeID, $form_errors);
             } else {
                 $type->process();
             }
         } else {
             $this->editIndividualType($typeID);
             // If not, just edit the type
         }
     }
 }
开发者ID:andrewheiss,项目名称:WP-Portfolio,代码行数:30,代码来源:portfolio.php

示例3: getOrganizerForComponentType

 /**
  * Answer the organizer above the reference node that can accept the component type given.
  * 
  * @param object SiteComponent $refNode
  * @param object Type $componentType
  * @return object OrganizerSiteComponent
  * @access public
  * @since 1/15/09
  * @static
  */
 public static function getOrganizerForComponentType(SiteComponent $refNode, Type $componentType)
 {
     // For pages and sections, find the menu above our component.
     if ($componentType->getDomain() == 'segue-multipart') {
         $parentComponent = $refNode->getParentComponent();
         while ($parentComponent) {
             if ($parentComponent->getComponentClass() == 'MenuOrganizer') {
                 return $parentComponent;
             }
             $parentComponent = $parentComponent->getParentComponent();
         }
         // If we didn't find a menu above our ref node, maybe we started in a heading.
         // Search down for a menu.
         $director = SiteDispatcher::getSiteDirector();
         $rootNode = $director->getRootSiteComponent($refNode->getId());
         $result = $rootNode->acceptVisitor(new GetMenuBelowSiteVisitor());
         if ($result) {
             return $result;
         }
         // If we still haven't found a menu, then there isn't one in this site.
         // Nothing more we can do.
         throw new OperationFailedException("Cannot create a " . $componentType->getKeyword() . ". Site " . $rootNode->getSlot()->getShortname() . " - '" . $rootNode->getDisplayName() . "' does not have any menus to add this component to.");
     } else {
         $parentComponent = $refNode->getParentComponent();
         while ($parentComponent) {
             if ($parentComponent->getComponentClass() == 'FlowOrganizer' || $parentComponent->getComponentClass() == 'MenuOrganizer') {
                 return $parentComponent;
             }
         }
         // If we haven't found a flow organizer above the refNode, something is wrong.
         throw new OperationFailedException("Cannot create a " . $componentType->getKeyword() . ". A ContentOrganizer was not found above reference node " . $refNode->getId());
     }
 }
开发者ID:adamfranco,项目名称:segue,代码行数:43,代码来源:process_add_wiki_component.act.php

示例4: check

 /**
  * This method checks if $value confirms to Type, if $value does not confirm to type, throws an exception or returns null if $soft is true
  *
  * @param            $value
  * @param string     $variableName Used in the message of the Exception, to ease debugging
  * @param bool       $soft
  *
  * @return mixed
  */
 public function check($value, $variableName = "unknown", $soft = false)
 {
     if ($value === null) {
         return null;
     }
     return $this->type->check($value, $variableName, $soft);
 }
开发者ID:mmagyar,项目名称:typage-php,代码行数:16,代码来源:Nullable.php

示例5: check

 function check($value = null, $schema = null, $path = null, $i = null)
 {
     $type = isset($schema->type) ? $schema->type : null;
     $isValid = true;
     if (is_array($type)) {
         $validatedOneType = false;
         $errors = array();
         foreach ($type as $tp) {
             $validator = new Type($this->checkMode);
             $subSchema = new \stdClass();
             $subSchema->type = $tp;
             $validator->check($value, $subSchema, $path, null);
             $error = $validator->getErrors();
             if (!count($error)) {
                 $validatedOneType = true;
                 break;
             } else {
                 $errors = $error;
             }
         }
         if (!$validatedOneType) {
             return $this->addErrors($errors);
         }
     } elseif (is_object($type)) {
         $this->checkUndefined($value, $type, $path);
     } else {
         $isValid = $this->validateType($value, $type);
     }
     if ($isValid === false) {
         $this->addError($path, gettype($value) . " value found, but a " . $type . " is required");
     }
 }
开发者ID:itillawarra,项目名称:cmfive,代码行数:32,代码来源:Type.php

示例6: buildContent

 /**
  * Build the content for this action
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $actionRows = $this->getActionRows();
     $harmoni = Harmoni::instance();
     ob_start();
     CollectionsPrinter::printFunctionLinks();
     print "<p>";
     print _("Below are listed the available <em>Collections</em>, organized by type, then name.");
     print "</p>\n<p>";
     print _("Some <em>Collections</em>, <em>Exhibitions</em>, <em>Assets</em>, and <em>Slide-Shows</em> may be restricted to certain users or groups of users. Log in above to ensure your greatest access to all parts of the system.");
     print "</p>";
     $actionRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, CENTER, CENTER);
     ob_end_clean();
     $exhibitionRepositoryType = new Type('System Repositories', 'edu.middlebury.concerto', 'Exhibitions');
     $repositoryManager = Services::getService("Repository");
     // Get all the types
     $types = $repositoryManager->getRepositoryTypes();
     // put the drs into an array and order them.
     $typeArray = array();
     while ($types->hasNext()) {
         $type = $types->next();
         // include all but Exhibitions repository.
         if (!$exhibitionRepositoryType->isEqual($type)) {
             $typeArray[HarmoniType::typeToString($type)] = $type;
         }
     }
     ksort($typeArray);
     // print the Results
     $resultPrinter = new ArrayResultPrinter($typeArray, 2, 20, "printTypeShort");
     $resultPrinter->addLinksStyleProperty(new MarginTopSP("10px"));
     $resultLayout = $resultPrinter->getLayout();
     $actionRows->add($resultLayout, null, null, CENTER, CENTER);
 }
开发者ID:adamfranco,项目名称:concerto,代码行数:40,代码来源:typebrowse.act.php

示例7: findByOwnerAndFilterWithPercents

 /**
  * Metodo que calcula el porcentaje de los tipos de gasto del usuario pasado
  * como parametro en funcion del rango de fechas pasado como parametro.
  * Para realizar el calculo, primero obtiene todos los gastos y la cantidad
  * numerica de gasto que representan. Despues se invoca a un metodo privado
  * para conocer el total de gasto del usuario y se calculan los porcentajes
  * de cada tipo de gasto. Finalmente, se crea un tipo de gasto especial que
  * representa el porcentaje de gasto de aquellos gastos que no tengan ningun
  * tipo de gasto asignado.
  */
 public function findByOwnerAndFilterWithPercents($owner, $startDate, $endDate)
 {
     $stmt = $this->db->prepare("SELECT SUM(s.quantity) as 'spending.quantity',\n                t.idType as 'type.id',\n                t.name as 'type.name'\n        FROM SPENDING s LEFT JOIN TYPE_SPENDING ts  ON s.idSpending = ts.spending LEFT JOIN TYPE t on ts.type = t.idType\n        WHERE s.owner = ?  AND s.dateSpending BETWEEN ? AND ? AND ts.spending IS NOT NULL GROUP BY ts.type");
     $stmt->execute(array($owner, $startDate, $endDate));
     $types_db = $stmt->fetchAll(PDO::FETCH_ASSOC);
     if (sizeof($types_db)) {
         $total = $this->getTotal($owner, $startDate, $endDate);
         $types = [];
         foreach ($types_db as $type_loop) {
             $type = new Type();
             $type->setName($type_loop['type.name']);
             $percent = $type_loop["spending.quantity"] * 100 / $total;
             array_push($types, array("typename" => $type->getName(), "percent" => round($percent, 2), "total" => (double) $type_loop["spending.quantity"]));
         }
         $totalWithoutType = $this->getTotalSpendingsWithoutType($owner, $startDate, $endDate);
         if ($totalWithoutType != 0) {
             $percentSpecialType = $totalWithoutType * 100 / $total;
             $specialType = new Type();
             $specialType->setName("Without category");
             array_push($types, array("typename" => $specialType->getName(), "percent" => round($percentSpecialType, 2), "total" => (double) $totalWithoutType));
         }
         return $types;
     } else {
         return NULL;
     }
 }
开发者ID:adri229,项目名称:wallas,代码行数:36,代码来源:TypeDAO.php

示例8: resolves

 public function resolves(Type $a, Type $b)
 {
     if ($a->equals($b)) {
         return true;
     }
     if ($a->type === Type::TYPE_LONG && $b->type === Type::TYPE_DOUBLE) {
         return true;
     }
     if ($a->type === Type::TYPE_USER && $b->type === Type::TYPE_USER) {
         foreach ($b->userTypes as $bt) {
             $bt = strtolower($bt);
             foreach ($a->userTypes as $at) {
                 $at = strtolower($at);
                 if (!isset($this->components['resolves'][$bt][$at])) {
                     continue 2;
                 }
             }
             // We got here, means we found an B type that's resolved by all A types
             return true;
         }
         // That means there is no A type that fully resolves at least one B type
         return false;
     }
     if (($b->type & $a->type) === $a->type) {
         return true;
     }
     return false;
 }
开发者ID:Tjoosten,项目名称:Tuli,代码行数:28,代码来源:TypeResolver.php

示例9: allows

 public function allows(Type $type) : bool
 {
     if ($type instanceof ComposedType) {
         return !in_array(false, array_map([$this, 'allows'], $type->decoratedTypes()));
     }
     return $type instanceof self;
 }
开发者ID:dkplus,项目名称:reflections,代码行数:7,代码来源:BooleanType.php

示例10: update

 public function update(Type $t)
 {
     $q = $this->_db->prepare('UPDATE Types SET libelle= :libelle WHERE id = :id');
     $q->bindValue(':id', $t->getId(), PDO::PARAM_INT);
     $q->bindValue(':libelle', $t->getLibelle(), PDO::PARAM_STR);
     $q->execute();
 }
开发者ID:abrantes01,项目名称:tripping-octo-nemesis,代码行数:7,代码来源:TypeManager.php

示例11: getVisitorLoginLink

function getVisitorLoginLink()
{
    $harmoni = Harmoni::instance();
    $authN = Services::getService("AuthN");
    // Visitor Registration Link
    $authTypes = $authN->getAuthenticationTypes();
    $hasVisitorType = false;
    $visitorType = new Type("Authentication", "edu.middlebury.harmoni", "Visitors");
    while ($authTypes->hasNext()) {
        $authType = $authTypes->next();
        if ($visitorType->isEqual($authType)) {
            $hasVisitorType = true;
            break;
        }
    }
    if ($hasVisitorType && !$authN->isUserAuthenticatedWithAnyType()) {
        $harmoni->request->startNamespace('polyphony');
        $url = $harmoni->request->mkURL("auth", "login_type");
        $url->setValue("type", urlencode($visitorType->asString()));
        // Add return info to the visitor registration url
        $visitorReturnModules = array('view', 'ui1', 'ui2', 'versioning');
        if (in_array($harmoni->request->getRequestedModule(), $visitorReturnModules)) {
            $url->setValue('returnModule', $harmoni->request->getRequestedModule());
            $url->setValue('returnAction', $harmoni->request->getRequestedAction());
            $url->setValue('returnKey', 'node');
            $url->setValue('returnValue', SiteDispatcher::getCurrentNodeId());
        }
        $harmoni->request->endNamespace();
        return "\n\t<a href='" . $url->write() . "'>" . _("Visitor Login") . "</a>";
    }
    return null;
}
开发者ID:adamfranco,项目名称:segue,代码行数:32,代码来源:authentication-cas_default.conf.php

示例12: __construct

 public function __construct(Type &$_typeObject)
 {
     $this->_typeObject = $_typeObject;
     $this->postType = $_typeObject->getPostType();
     $args = $_typeObject->getQueryArgs();
     parent::__construct($args, $this->postType);
 }
开发者ID:potterywp,项目名称:potter,代码行数:7,代码来源:QueryModel.php

示例13: generate

 /**
  * @param Type $type
  * @param $appId
  * @return PushCertificate
  */
 public function generate(Type $type, $appId)
 {
     $app = $this->portalConnection->fetchApp($appId);
     $privateKey = new PrivateKey();
     $csrCommonName = $app->getName() . ' ' . $type->getHumanReadable() . ' Push Certificate';
     $signingRequest = new SigningRequest($privateKey, $csrCommonName, $this->portalConnection->getAppleId());
     return new PushCertificate($privateKey, $this->portalConnection->signCertificate($signingRequest, $type, $app->getAppIdId()));
 }
开发者ID:genkgo,项目名称:push,代码行数:13,代码来源:Generator.php

示例14: testIsAndToString

 public function testIsAndToString()
 {
     foreach (array(Type::CHOICE, Type::IDENTIFIER, Type::LOOP, Type::OPTION, Type::RANGE, Type::RULE, Type::SEQUENCE, Type::SYNTAX, Type::TERMINAL) as $typeName) {
         $t = new Type($typeName);
         $this->assertTrue($t->is($typeName));
         $this->assertEquals($typeName, $t->__toString());
     }
 }
开发者ID:bgarrels,项目名称:ebnf,代码行数:8,代码来源:TypeTest.php

示例15: setType

 /**
  * Sets the document type name.
  *
  * @param Type|string $type Type name
  *
  * @return $this
  */
 public function setType($type)
 {
     if ($type instanceof Type) {
         $this->setIndex($type->getIndex());
         $type = $type->getName();
     }
     return $this->setParam('_type', $type);
 }
开发者ID:ruflin,项目名称:elastica,代码行数:15,代码来源:AbstractUpdateAction.php


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