當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。