File indexing completed on 2025-01-26 05:30:00

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Tool
0017  * @subpackage Framework
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 /**
0024  * @see Zend_Tool_Framework_Registry_EnabledInterface
0025  */
0026 // require_once 'Zend/Tool/Framework/Registry/EnabledInterface.php';
0027 
0028 /**
0029  * @see Zend_Tool_Framework_Provider_Interface
0030  */
0031 // require_once 'Zend/Tool/Framework/Provider/Interface.php';
0032 
0033 /**
0034  * @category   Zend
0035  * @package    Zend_Tool
0036  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0037  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0038  */
0039 class Zend_Tool_Framework_System_Provider_Manifest
0040     implements Zend_Tool_Framework_Provider_Interface, Zend_Tool_Framework_Registry_EnabledInterface
0041 {
0042 
0043     public function setRegistry(Zend_Tool_Framework_Registry_Interface $registry)
0044     {
0045         $this->_registry = $registry;
0046     }
0047 
0048     public function getName()
0049     {
0050         return 'Manifest';
0051     }
0052 
0053     public function show()
0054     {
0055 
0056         $manifestRepository = $this->_registry->getManifestRepository();
0057         $response           = $this->_registry->getResponse();
0058 
0059         $metadataTree = array();
0060 
0061         $longestAttrNameLen = 50;
0062 
0063         foreach ($manifestRepository as $metadata) {
0064 
0065             $metadataType  = $metadata->getType();
0066             $metadataName  = $metadata->getName();
0067             $metadataAttrs = $metadata->getAttributes('attributesParent');
0068 
0069             if (!$metadataAttrs) {
0070                 $metadataAttrs = '(None)';
0071             } else {
0072                 $metadataAttrs = urldecode(http_build_query($metadataAttrs, null, ', '));
0073             }
0074 
0075             if (!array_key_exists($metadataType, $metadataTree)) {
0076                 $metadataTree[$metadataType] = array();
0077             }
0078 
0079             if (!array_key_exists($metadataName, $metadataTree[$metadataType])) {
0080                 $metadataTree[$metadataType][$metadataName] = array();
0081             }
0082 
0083             if (!array_key_exists($metadataAttrs, $metadataTree[$metadataType][$metadataName])) {
0084                 $metadataTree[$metadataType][$metadataName][$metadataAttrs] = array();
0085             }
0086 
0087             $longestAttrNameLen = (strlen($metadataAttrs) > $longestAttrNameLen) ? strlen($metadataAttrs) : $longestAttrNameLen;
0088 
0089             $metadataValue = $metadata->getValue();
0090             if (is_array($metadataValue) && count($metadataValue) > 0) {
0091                 $metadataValue = urldecode(http_build_query($metadataValue, null, ', '));
0092             } elseif (is_array($metadataValue)) {
0093                 $metadataValue = '(empty array)';
0094             }
0095 
0096             $metadataTree[$metadataType][$metadataName][$metadataAttrs][] = $metadataValue;
0097         }
0098 
0099         foreach ($metadataTree as $metadataType => $metadatasByName) {
0100             $response->appendContent($metadataType);
0101             foreach ($metadatasByName as $metadataName => $metadatasByAttributes) {
0102                 $response->appendContent("   " . $metadataName);
0103                 foreach ($metadatasByAttributes as $metadataAttributeName => $metadataValues) {
0104                     foreach ($metadataValues as $metadataValue) {
0105                         $string = sprintf("      %-{$longestAttrNameLen}.{$longestAttrNameLen}s : ", $metadataAttributeName)
0106                             . $metadataValue;
0107                         $response->appendContent($string);
0108                     }
0109                 }
0110             }
0111         }
0112 
0113     }
0114 }