當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。