getData() public method

Get stored data
public getData ( string $key ) : mixed
$key string The key for the requested key/value pair
return mixed
Example #1
0
 /**
  * Compare two menu items by their priority
  *
  * @param ElggMenuItem $a Menu item
  * @param ElggMenuItem $b Menu item
  * @return bool
  *
  * @todo change name to compareByPriority
  */
 public static function compareByWeight($a, $b)
 {
     $aw = $a->getWeight();
     $bw = $b->getWeight();
     if ($aw == $bw) {
         return $a->getData('original_order') - $b->getData('original_order');
     }
     return $aw - $bw;
 }
Example #2
0
 /**
  * Compare two menu items by their priority
  *
  * @param \ElggMenuItem $a Menu item
  * @param \ElggMenuItem $b Menu item
  * @return bool
  * @deprecated 1.9 Use compareByPriority()
  */
 public static function compareByWeight($a, $b)
 {
     elgg_deprecated_notice("\\ElggMenuBuilder::compareByWeight() deprecated by \\ElggMenuBuilder::compareByPriority", 1.9);
     $aw = $a->getPriority();
     $bw = $b->getPriority();
     if ($aw == $bw) {
         return $a->getData('original_order') - $b->getData('original_order');
     }
     return $aw - $bw;
 }
Example #3
0
 public function testGetDataNonExistentKey()
 {
     $item = new \ElggMenuItem('name', 'text', 'url');
     $this->assertNull($item->getData('blah'));
 }