示例#1
0
 /**
  * @covers \Magento\Framework\View\Design\Theme\Label::getLabelsCollection
  */
 public function testGetLabelsCollection()
 {
     /** @var $expectedCollection \Magento\Core\Model\Resource\Theme\Collection */
     $expectedCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\View\\Design\\Theme\\Label\\ListInterface');
     $expectedItemsCount = count($expectedCollection->getLabels());
     $labelsCollection = $this->_model->getLabelsCollection();
     $this->assertEquals($expectedItemsCount, count($labelsCollection));
     $labelsCollection = $this->_model->getLabelsCollection('-- Please Select --');
     $this->assertEquals(++$expectedItemsCount, count($labelsCollection));
 }
示例#2
0
 /**
  * Return labels collection array
  *
  * @param bool|string $label add empty values to result with specific label
  * @return array
  */
 public function getLabelsCollection($label = false)
 {
     $options = parent::getLabelsCollection();
     if ($label) {
         array_unshift($options, ['value' => 0, 'label' => $label]);
     }
     return $options;
 }
示例#3
0
文件: Theme.php 项目: aiesh/magento2
 /**
  * Retrieve All Design Theme Options
  *
  * @param bool $withEmpty add empty (please select) values to result
  * @return Label[]
  */
 public function getAllOptions($withEmpty = true)
 {
     $label = $withEmpty ? __('-- Please Select --') : $withEmpty;
     return $this->_options = $this->themeLabel->getLabelsCollection($label);
 }