当前位置: 首页>>代码示例>>PHP>>正文


PHP StreamInterface::addCss方法代码示例

本文整理汇总了PHP中Psr\Http\Message\StreamInterface::addCss方法的典型用法代码示例。如果您正苦于以下问题:PHP StreamInterface::addCss方法的具体用法?PHP StreamInterface::addCss怎么用?PHP StreamInterface::addCss使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Psr\Http\Message\StreamInterface的用法示例。


在下文中一共展示了StreamInterface::addCss方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: toContentType

 /**
  * Build a ContentType object
  *
  * This method takes the root (a node) of the page's content tree (records from the contents table))
  * and transforms it into a corresponding tree of content elements for rendering.
  *
  * The database fields have the following meaning:
  *
  * `name`         - a page-wide unique name (id) for the element. SHOULD be used as id attribute.
  * `content_type` - fully qualified classname of the content element.
  * `content_args` - constructor parameters for the content element.
  * `component`    - name of the entity containing data for the content element.
  * `selection`    - selection criteria for the data entity.
  * `params`       - additional parameters for use by the layout file.
  *
  * @param Content $root
  *
  * @return ContentTypeInterface[]
  */
 private function toContentType($root)
 {
     #echo "<pre>" . __METHOD__ . ' ' . $this->dumpEntity($root) . "\n";
     #echo "Data selection: " . $root->component . ' ' . print_r($root->selection, true) . "\n";
     $contentType = $root->contentType;
     $data = $this->findData($root->component, $root->selection);
     $reflector = new \ReflectionClass($contentType);
     $constructor = $reflector->getConstructor();
     $constructorParameters = null;
     if (!empty($constructor)) {
         $constructorParameters = $constructor->getParameters();
     }
     $all = [];
     foreach (array_values($data) as $index => $item) {
         #echo "<pre>";
         #echo "Data item: " . $this->dumpEntity($item) . "\n";
         /** @var AbstractContentType $content */
         $providedArguments = empty($root->contentArgs) ? [] : get_object_vars($root->contentArgs);
         $actualArguments = [];
         foreach ($constructorParameters as $parameter) {
             $name = $parameter->getName();
             $defaultValue = $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null;
             if ($name == 'item') {
                 $defaultValue = $item;
             }
             $actualArguments[$name] = isset($providedArguments[$name]) ? $providedArguments[$name] : $defaultValue;
         }
         $content = $reflector->newInstanceArgs($actualArguments);
         $content->setId($index == 0 ? $root->name : $root->name . '-' . $index);
         $content->setParameters($root->params);
         if (!empty($root->customCss)) {
             $this->output->addCss($content->getId(), $root->customCss);
         }
         #echo "Content: " . get_class($content) . "\n";
         if ($content instanceof CompoundTypeInterface) {
             /** @noinspection PhpUndefinedFieldInspection */
             foreach ($root->children as $node) {
                 #echo "<pre>";
                 #echo "Child: " . $node->name . " (" . $node->contentType . ")\n";
                 foreach ($this->toContentType($node) as $child) {
                     #echo "Result: " . get_class($child) . "\n";
                     $content->add($child);
                 }
                 #echo "</pre>";
             }
         }
         $all[] = $content;
         #echo "</pre>";
     }
     #echo "</pre>";
     return $all;
 }
开发者ID:nibra,项目名称:joomla-pythagoras,代码行数:71,代码来源:DisplayPageCommandHandler.php


注:本文中的Psr\Http\Message\StreamInterface::addCss方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。