getTypes() публичный Метод

С версии: 1.9.0
public getTypes ( array $params = [] ) : WidgetDefinition[]
$params array Associative array of params used to determine what to return array ( 'context' => string (defaults to elgg_get_context()), 'container' => \ElggEntity (defaults to null) )
Результат WidgetDefinition[]
Пример #1
0
 /**
  * @depends testRegistrationParametersPreserveMultiple
  * @param \Elgg\WidgetsService $service
  */
 public function testRegistrationParametersPreserveNameDescription($service)
 {
     $resps = array('widget_type' => array('Widget name1', 'Widget description1'), 'widget_type_con' => array('Widget name2', 'Widget description2'), 'widget_type_mul' => array('Widget name3', 'Widget description3'), 'widget_type_con_mul' => array('Widget name5', 'Widget description5'));
     $contexts = array('dashboard', 'profile', 'settings');
     foreach ($contexts as $context) {
         $items = $service->getTypes(['context' => $context]);
         foreach ($items as $id => $item) {
             $this->assertInstanceOf('\\Elgg\\WidgetDefinition', $item);
             $this->assertNotEmpty($id);
             $this->assertInternalType('string', $id);
             $this->assertArrayHasKey($id, $resps);
             list($name, $desc) = $resps[$id];
             $this->assertSame($name, $item->name);
             $this->assertSame($desc, $item->description);
         }
     }
     return $service;
 }
Пример #2
0
 /**
  * @depends testRegistrationParametersPreserveMultiple
  * @param \Elgg\WidgetsService $service
  */
 public function testRegistrationParametersPreserveNameDescription($service)
 {
     $resps = array('widget_type' => array('Widget name1', 'Widget description1'), 'widget_type_con' => array('Widget name2', 'Widget description2'), 'widget_type_mul' => array('Widget name3', 'Widget description3'), 'widget_type_con_mul' => array('Widget name5', 'Widget description5'));
     $contexts = array('all', 'dashboard', 'profile', 'settings');
     foreach (array(false, true) as $exact) {
         foreach ($contexts as $context) {
             $items = $service->getTypes($context, $exact);
             foreach ($items as $handler => $item) {
                 $this->assertInstanceOf('\\stdClass', $item);
                 $this->assertNotEmpty($handler);
                 $this->assertInternalType('string', $handler);
                 $this->assertArrayHasKey($handler, $resps);
                 list($name, $desc) = $resps[$handler];
                 $this->assertSame($name, $item->name);
                 $this->assertSame($desc, $item->description);
             }
         }
     }
     return $service;
 }