Example #1
0
 /**
  * Returns the default class for a property name.
  *
  * @param string $propertyName
  * @return string
  */
 public function getClassNameForPropertyName($propertyName)
 {
     $className = parent::getClassNameForPropertyName($propertyName);
     // In vCard 4, BINARY no longer exists, and we need URI instead.
     if ($className == 'SabreForRainLoop\\VObject\\Property\\Binary' && $this->getDocumentType() === self::VCARD40) {
         return 'SabreForRainLoop\\VObject\\Property\\Uri';
     }
     return $className;
 }
Example #2
0
 /**
  * Validates the node for correctness.
  * 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)
  *
  * @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 VCALENDAR component exactly 1 time', 'node' => $this);
     } else {
         if ((string) $this->VERSION !== '2.0') {
             $warnings[] = array('level' => 1, 'message' => 'Only iCalendar version 2.0 as defined in rfc5545 is supported.', 'node' => $this);
         }
     }
     $version = $this->select('PRODID');
     if (count($version) !== 1) {
         $warnings[] = array('level' => 2, 'message' => 'The PRODID property must appear in the VCALENDAR component exactly 1 time', 'node' => $this);
     }
     if (count($this->CALSCALE) > 1) {
         $warnings[] = array('level' => 2, 'message' => 'The CALSCALE property must not be specified more than once.', 'node' => $this);
     }
     if (count($this->METHOD) > 1) {
         $warnings[] = array('level' => 2, 'message' => 'The METHOD property must not be specified more than once.', 'node' => $this);
     }
     $componentsFound = 0;
     foreach ($this->children as $child) {
         if ($child instanceof Component) {
             $componentsFound++;
         }
     }
     if ($componentsFound === 0) {
         $warnings[] = array('level' => 1, 'message' => 'An iCalendar object must have at least 1 component.', 'node' => $this);
     }
     return array_merge($warnings, parent::validate());
 }