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


PHP Component::validate方法代码示例

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


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

示例1: validate

 /**
  * Validates the node for correctness.
  *
  * The following options are supported:
  *   Node::REPAIR - May attempt to automatically repair the problem.
  *   Node::PROFILE_CARDDAV - validate the vCard for CardDAV purposes.
  *   Node::PROFILE_CALDAV - validate the iCalendar for CalDAV purposes.
  *
  * This method returns an array with detected problems.
  * Every element has the following properties:
  *
  *  * level - problem level.
  *  * message - A human-readable string describing the issue.
  *  * node - A reference to the problematic node.
  *
  * The level means:
  *   1 - The issue was repaired (only happens if REPAIR was turned on).
  *   2 - A warning.
  *   3 - An error.
  *
  * @param int $options
  * @return array
  */
 function validate($options = 0)
 {
     $result = parent::validate($options);
     if (isset($this->DTEND) && isset($this->DURATION)) {
         $result[] = array('level' => 3, 'message' => 'DTEND and DURATION cannot both be present', 'node' => $this);
     }
     return $result;
 }
开发者ID:zhuomingliang,项目名称:webmail-lite,代码行数:31,代码来源:VAvailability.php

示例2: validate

 /**
  * Validates the node for correctness.
  *
  * The following options are supported:
  *   Node::REPAIR - May attempt to automatically repair the problem.
  *   Node::PROFILE_CARDDAV - Validate the vCard for CardDAV purposes.
  *   Node::PROFILE_CALDAV - Validate the iCalendar for CalDAV purposes.
  *
  * This method returns an array with detected problems.
  * Every element has the following properties:
  *
  *  * level - problem level.
  *  * message - A human-readable string describing the issue.
  *  * node - A reference to the problematic node.
  *
  * The level means:
  *   1 - The issue was repaired (only happens if REPAIR was turned on).
  *   2 - A warning.
  *   3 - An error.
  *
  * @param int $options
  *
  * @return array
  */
 function validate($options = 0)
 {
     $result = parent::validate($options);
     if (isset($this->DTEND) && isset($this->DURATION)) {
         $result[] = ['level' => 3, 'message' => 'DTEND and DURATION cannot both be present', 'node' => $this];
     }
     if (isset($this->DURATION) && !isset($this->DTSTART)) {
         $result[] = ['level' => 3, 'message' => 'DURATION must be declared with a DTSTART.', 'node' => $this];
     }
     return $result;
 }
开发者ID:royopa,项目名称:sabre-vobject,代码行数:35,代码来源:Available.php

示例3: validate

 /**
  * Validates the node for correctness.
  *
  * The following options are supported:
  *   - Node::REPAIR - If something is broken, and automatic repair may
  *                    be attempted.
  *
  * An array is returned with warnings.
  *
  * Every item in the array has the following properties:
  *    * level - (number between 1 and 3 with severity information)
  *    * message - (human readable message)
  *    * node - (reference to the offending node)
  *
  * @param int $options
  * @return array
  */
 public function validate($options = 0)
 {
     $warnings = array();
     $version = $this->select('VERSION');
     if (count($version) !== 1) {
         $warnings[] = array('level' => 1, 'message' => 'The VERSION property must appear in the VCARD component exactly 1 time', 'node' => $this);
         if ($options & self::REPAIR) {
             $this->VERSION = self::DEFAULT_VERSION;
         }
     } else {
         $version = (string) $this->VERSION;
         if ($version !== '2.1' && $version !== '3.0' && $version !== '4.0') {
             $warnings[] = array('level' => 1, 'message' => 'Only vcard version 4.0 (RFC6350), version 3.0 (RFC2426) or version 2.1 (icm-vcard-2.1) are supported.', 'node' => $this);
             if ($options & self::REPAIR) {
                 $this->VERSION = '4.0';
             }
         }
     }
     $fn = $this->select('FN');
     if (count($fn) !== 1) {
         $warnings[] = array('level' => 1, 'message' => 'The FN property must appear in the VCARD component exactly 1 time', 'node' => $this);
         if ($options & self::REPAIR && count($fn) === 0) {
             // We're going to try to see if we can use the contents of the
             // N property.
             if (isset($this->N)) {
                 $value = explode(';', (string) $this->N);
                 if (isset($value[1]) && $value[1]) {
                     $this->FN = $value[1] . ' ' . $value[0];
                 } else {
                     $this->FN = $value[0];
                 }
                 // Otherwise, the ORG property may work
             } elseif (isset($this->ORG)) {
                 $this->FN = (string) $this->ORG;
             }
         }
     }
     return array_merge(parent::validate($options), $warnings);
 }
开发者ID:thermalpaste,项目名称:pydio-core,代码行数:56,代码来源:VCard.php

示例4: validate

 /**
  * Validates the node for correctness.
  *
  * The following options are supported:
  *   Node::REPAIR - May attempt to automatically repair the problem.
  *
  * This method returns an array with detected problems.
  * Every element has the following properties:
  *
  *  * level - problem level.
  *  * message - A human-readable string describing the issue.
  *  * node - A reference to the problematic node.
  *
  * The level means:
  *   1 - The issue was repaired (only happens if REPAIR was turned on)
  *   2 - An inconsequential issue
  *   3 - A severe issue.
  *
  * @param int $options
  * @return array
  */
 public function validate($options = 0)
 {
     $result = parent::validate($options);
     if (isset($this->DUE) && isset($this->DTSTART)) {
         $due = $this->DUE;
         $dtStart = $this->DTSTART;
         if ($due->getValueType() !== $dtStart->getValueType()) {
             $result[] = array('level' => 3, 'message' => 'The value type (DATE or DATE-TIME) must be identical for DUE and DTSTART', 'node' => $due);
         } elseif ($due->getDateTime() < $dtStart->getDateTime()) {
             $result[] = array('level' => 3, 'message' => 'DUE must occur after DTSTART', 'node' => $due);
         }
     }
     return $result;
 }
开发者ID:LobbyOS,项目名称:server,代码行数:35,代码来源:VTodo.php

示例5: repair

 /**
  * Repairs a VObject file
  *
  * @param Component $vObj
  * @return int
  */
 protected function repair($vObj)
 {
     $returnCode = 0;
     switch ($vObj->name) {
         case 'VCALENDAR':
             $this->log("iCalendar: " . (string) $vObj->VERSION);
             break;
         case 'VCARD':
             $this->log("vCard: " . (string) $vObj->VERSION);
             break;
     }
     $warnings = $vObj->validate(Node::REPAIR);
     if (!count($warnings)) {
         $this->log("  No warnings!");
     } else {
         $levels = [1 => 'REPAIRED', 2 => 'WARNING', 3 => 'ERROR'];
         $returnCode = 2;
         foreach ($warnings as $warn) {
             $extra = '';
             if ($warn['node'] instanceof Property) {
                 $extra = ' (property: "' . $warn['node']->name . '")';
             }
             $this->log("  [" . $levels[$warn['level']] . '] ' . $warn['message'] . $extra);
         }
     }
     fwrite($this->stdout, $vObj->serialize());
     return $returnCode;
 }
开发者ID:mirabilos,项目名称:sabre-vobject,代码行数:34,代码来源:Cli.php

示例6: repair

 /**
  * Repairs a VObject file
  *
  * @param Component $vObj
  * @return int
  */
 protected function repair($vObj)
 {
     $returnCode = 0;
     switch ($vObj->name) {
         case 'VCALENDAR':
             $this->log("iCalendar: " . (string) $vObj->VERSION);
             break;
         case 'VCARD':
             $this->log("vCard: " . (string) $vObj->VERSION);
             break;
     }
     $warnings = $vObj->validate(Node::REPAIR);
     if (!count($warnings)) {
         $this->log("  No warnings!");
     } else {
         foreach ($warnings as $warn) {
             $returnCode = 2;
             $this->log("  " . $warn['message']);
         }
     }
     fwrite($this->stdout, $vObj->serialize());
     return $returnCode;
 }
开发者ID:hiaio-platform-medical,项目名称:rainloop-webmail,代码行数:29,代码来源:Cli.php


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