Пример #1
0
 /**
  * 2015-11-14
  * Цель плагина — алфавитное упорядочивание моих модулей
  * в разделе административных настроек модулей.
  * @see \Magento\Config\Model\Config\Structure\Element\Iterator\Tab::setElements()
  * @param Sb $sb
  * @param array(string => array(string => string)) $elements
  * @param string $scope
  * @return array()
  */
 public function beforeSetElements(Sb $sb, array $elements, $scope)
 {
     /** @var array(string => string)|null $sections */
     $sections = dfa_deep($elements, '_df/children');
     if ($sections) {
         uasort($sections, function ($a, $b) {
             return strcasecmp(dfa($a, 'label'), dfa($b, 'label'));
         });
         $elements['_df']['children'] = $sections;
     }
     return [$elements, $scope];
 }
Пример #2
0
 /**
  * 2016-07-01
  * @override
  * @see \Magento\Config\Block\System\Config\Form\Fieldset::_getHeaderCommentHtml()
  * https://github.com/magento/magento2/blob/2.1.0/app/code/Magento/Config/Block/System/Config/Form/Fieldset.php#L166-L175
  * @used-by \Magento\Config\Block\System\Config\Form\Fieldset::_getHeaderHtml()
  * https://github.com/magento/magento2/blob/2.1.0/app/code/Magento/Config/Block/System/Config/Form/Fieldset.php#L121
  * @param AE|F $element
  * @return string
  */
 protected function _getHeaderCommentHtml($element)
 {
     /** @var string|null $infoClass */
     $infoClass = dfa_deep($element->getData(), 'group/dfExtension');
     /** @var string $result */
     if (!$infoClass) {
         $result = parent::_getHeaderCommentHtml($element);
     } else {
         /** @var \Df\Config\Ext $extensionInfo */
         $info = df_o($infoClass);
         $result = df_tag('div', 'comment', df_tag_ab(__('Have a question?'), $info->url()));
     }
     return $result;
 }
Пример #3
0
/**
 * 2016-08-22
 * @param DataObject|C|null $c [optional]
 * @param string $path [optional]
 * @param string|array(string => mixed)|null $default [optional]
 * @return string|array(string => mixed)|null
 */
function df_customer_info_get(DataObject $c = null, $path = null, $default = null)
{
    $c = $c ?: df_current_customer();
    /** @var string|array(string => mixed)|null $result */
    if (!$c) {
        $result = null;
    } else {
        /** @var string $json */
        $json = $c[Schema::F__DF];
        /** @var array(string => mixed) $array */
        $array = is_null($json) ? [] : df_json_decode($json);
        $result = is_null($path) ? $array : dfa_deep($array, $path, $default);
    }
    return $result;
}
Пример #4
0
 /**
  * 2016-08-21
  * https://3v4l.org/2J6sp
  * @param string|string[]|null $items [optional]
  * @param mixed|null $default [optional]
  * @return mixed|array(string => mixed)|null
  */
 public function a($items = null, $default = null)
 {
     return is_null($items) ? $this->_data : (is_array($items) ? array_map([$this, __FUNCTION__], $items) : dfa_deep($this->_data, $items, $default));
 }
Пример #5
0
 /**
  * 2015-12-07
  * 2016-01-01
  * Сегодня заметил, что Magento 2, в отличие от Magento 1.x,
  * допускает иерархическую вложенность групп настроек большую, чем 3, например:
  * https://github.com/magento/magento2/blob/2.0.0/app/code/Magento/Cron/etc/adminhtml/system.xml#L14
  * В Magento 1.x вложенность всегда такова: section / group / field.
  * В Magento 2 вложенность может быть такой: section / group / group / field.
  * @return array(string => mixed)
  */
 protected function value()
 {
     return dfc($this, function () {
         /** @var string[] $pathA */
         $pathA = array_slice(df_explode_xpath($this->getPath()), 1);
         /** @var string $fieldName */
         $fieldName = array_pop($pathA);
         /** @var string $path */
         $path = 'groups/' . implode('/groups/', $pathA) . '/fields/' . $fieldName;
         /** @var array(string => mixed) $result */
         /**
          * 2016-09-02
          * При сохранении настроек вне области действия по умолчанию
          * в результат попадает ключ «inherit». Удаляем его.
          * https://code.dmitry-fedyuk.com/m2e/allpay/issues/24
          */
         $result = dfa_unset(dfa_deep($this->_data, $path), 'inherit');
         df_result_array($result);
         return $result;
     });
 }
Пример #6
0
/**
 * 2015-08-23
 * Обратите внимание, что метод
 * @see Varien_Db_Adapter_Pdo_Mysql::getPrimaryKeyName()
 * возвращает не название колонки, а слово «PRIMARY»,
 * поэтому он нам не подходит.
 * @used-by Df_Localization_Onetime_Dictionary_Db_Table::primaryKey()
 * @param string $table
 * @return string|null
 */
function df_primary_key($table)
{
    return dfcf(function ($table) {
        return df_first(df_nta(dfa_deep(df_conn()->getIndexList($table), 'PRIMARY/COLUMNS_LIST')));
    }, func_get_args());
}