bootstrap.php.cache 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136
  1. <?php
  2. namespace { $loader = require_once __DIR__.'/autoload.php'; }
  3. namespace Symfony\Component\DependencyInjection
  4. {
  5. interface ContainerAwareInterface
  6. {
  7. public function setContainer(ContainerInterface $container = null);
  8. }
  9. }
  10. namespace Symfony\Component\DependencyInjection
  11. {
  12. use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
  13. use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
  14. use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
  15. interface ContainerInterface
  16. {
  17. const EXCEPTION_ON_INVALID_REFERENCE = 1;
  18. const NULL_ON_INVALID_REFERENCE = 2;
  19. const IGNORE_ON_INVALID_REFERENCE = 3;
  20. const SCOPE_CONTAINER ='container';
  21. const SCOPE_PROTOTYPE ='prototype';
  22. public function set($id, $service, $scope = self::SCOPE_CONTAINER);
  23. public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE);
  24. public function has($id);
  25. public function getParameter($name);
  26. public function hasParameter($name);
  27. public function setParameter($name, $value);
  28. public function enterScope($name);
  29. public function leaveScope($name);
  30. public function addScope(ScopeInterface $scope);
  31. public function hasScope($name);
  32. public function isScopeActive($name);
  33. }
  34. }
  35. namespace Symfony\Component\DependencyInjection
  36. {
  37. interface IntrospectableContainerInterface extends ContainerInterface
  38. {
  39. public function initialized($id);
  40. }
  41. }
  42. namespace Symfony\Component\DependencyInjection
  43. {
  44. use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
  45. use Symfony\Component\DependencyInjection\Exception\RuntimeException;
  46. use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
  47. use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
  48. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  49. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
  50. use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
  51. class Container implements IntrospectableContainerInterface
  52. {
  53. protected $parameterBag;
  54. protected $services;
  55. protected $scopes;
  56. protected $scopeChildren;
  57. protected $scopedServices;
  58. protected $scopeStacks;
  59. protected $loading = array();
  60. public function __construct(ParameterBagInterface $parameterBag = null)
  61. {
  62. $this->parameterBag = null === $parameterBag ? new ParameterBag() : $parameterBag;
  63. $this->services = array();
  64. $this->scopes = array();
  65. $this->scopeChildren = array();
  66. $this->scopedServices = array();
  67. $this->scopeStacks = array();
  68. $this->set('service_container', $this);
  69. }
  70. public function compile()
  71. {
  72. $this->parameterBag->resolve();
  73. $this->parameterBag = new FrozenParameterBag($this->parameterBag->all());
  74. }
  75. public function isFrozen()
  76. {
  77. return $this->parameterBag instanceof FrozenParameterBag;
  78. }
  79. public function getParameterBag()
  80. {
  81. return $this->parameterBag;
  82. }
  83. public function getParameter($name)
  84. {
  85. return $this->parameterBag->get($name);
  86. }
  87. public function hasParameter($name)
  88. {
  89. return $this->parameterBag->has($name);
  90. }
  91. public function setParameter($name, $value)
  92. {
  93. $this->parameterBag->set($name, $value);
  94. }
  95. public function set($id, $service, $scope = self::SCOPE_CONTAINER)
  96. {
  97. if (self::SCOPE_PROTOTYPE === $scope) {
  98. throw new InvalidArgumentException(sprintf('You cannot set service "%s" of scope "prototype".', $id));
  99. }
  100. $id = strtolower($id);
  101. if (self::SCOPE_CONTAINER !== $scope) {
  102. if (!isset($this->scopedServices[$scope])) {
  103. throw new RuntimeException(sprintf('You cannot set service "%s" of inactive scope.', $id));
  104. }
  105. $this->scopedServices[$scope][$id] = $service;
  106. }
  107. $this->services[$id] = $service;
  108. }
  109. public function has($id)
  110. {
  111. $id = strtolower($id);
  112. return isset($this->services[$id]) || method_exists($this,'get'.strtr($id, array('_'=>'','.'=>'_')).'Service');
  113. }
  114. public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE)
  115. {
  116. $id = strtolower($id);
  117. if (isset($this->services[$id])) {
  118. return $this->services[$id];
  119. }
  120. if (isset($this->loading[$id])) {
  121. throw new ServiceCircularReferenceException($id, array_keys($this->loading));
  122. }
  123. if (method_exists($this, $method ='get'.strtr($id, array('_'=>'','.'=>'_')).'Service')) {
  124. $this->loading[$id] = true;
  125. try {
  126. $service = $this->$method();
  127. } catch (\Exception $e) {
  128. unset($this->loading[$id]);
  129. if (isset($this->services[$id])) {
  130. unset($this->services[$id]);
  131. }
  132. throw $e;
  133. }
  134. unset($this->loading[$id]);
  135. return $service;
  136. }
  137. if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) {
  138. throw new ServiceNotFoundException($id);
  139. }
  140. }
  141. public function initialized($id)
  142. {
  143. return isset($this->services[strtolower($id)]);
  144. }
  145. public function getServiceIds()
  146. {
  147. $ids = array();
  148. $r = new \ReflectionClass($this);
  149. foreach ($r->getMethods() as $method) {
  150. if (preg_match('/^get(.+)Service$/', $method->name, $match)) {
  151. $ids[] = self::underscore($match[1]);
  152. }
  153. }
  154. return array_unique(array_merge($ids, array_keys($this->services)));
  155. }
  156. public function enterScope($name)
  157. {
  158. if (!isset($this->scopes[$name])) {
  159. throw new InvalidArgumentException(sprintf('The scope "%s" does not exist.', $name));
  160. }
  161. if (self::SCOPE_CONTAINER !== $this->scopes[$name] && !isset($this->scopedServices[$this->scopes[$name]])) {
  162. throw new RuntimeException(sprintf('The parent scope "%s" must be active when entering this scope.', $this->scopes[$name]));
  163. }
  164. if (isset($this->scopedServices[$name])) {
  165. $services = array($this->services, $name => $this->scopedServices[$name]);
  166. unset($this->scopedServices[$name]);
  167. foreach ($this->scopeChildren[$name] as $child) {
  168. if (isset($this->scopedServices[$child])) {
  169. $services[$child] = $this->scopedServices[$child];
  170. unset($this->scopedServices[$child]);
  171. }
  172. }
  173. $this->services = call_user_func_array('array_diff_key', $services);
  174. array_shift($services);
  175. if (!isset($this->scopeStacks[$name])) {
  176. $this->scopeStacks[$name] = new \SplStack();
  177. }
  178. $this->scopeStacks[$name]->push($services);
  179. }
  180. $this->scopedServices[$name] = array();
  181. }
  182. public function leaveScope($name)
  183. {
  184. if (!isset($this->scopedServices[$name])) {
  185. throw new InvalidArgumentException(sprintf('The scope "%s" is not active.', $name));
  186. }
  187. $services = array($this->services, $this->scopedServices[$name]);
  188. unset($this->scopedServices[$name]);
  189. foreach ($this->scopeChildren[$name] as $child) {
  190. if (!isset($this->scopedServices[$child])) {
  191. continue;
  192. }
  193. $services[] = $this->scopedServices[$child];
  194. unset($this->scopedServices[$child]);
  195. }
  196. $this->services = call_user_func_array('array_diff_key', $services);
  197. if (isset($this->scopeStacks[$name]) && count($this->scopeStacks[$name]) > 0) {
  198. $services = $this->scopeStacks[$name]->pop();
  199. $this->scopedServices += $services;
  200. array_unshift($services, $this->services);
  201. $this->services = call_user_func_array('array_merge', $services);
  202. }
  203. }
  204. public function addScope(ScopeInterface $scope)
  205. {
  206. $name = $scope->getName();
  207. $parentScope = $scope->getParentName();
  208. if (self::SCOPE_CONTAINER === $name || self::SCOPE_PROTOTYPE === $name) {
  209. throw new InvalidArgumentException(sprintf('The scope "%s" is reserved.', $name));
  210. }
  211. if (isset($this->scopes[$name])) {
  212. throw new InvalidArgumentException(sprintf('A scope with name "%s" already exists.', $name));
  213. }
  214. if (self::SCOPE_CONTAINER !== $parentScope && !isset($this->scopes[$parentScope])) {
  215. throw new InvalidArgumentException(sprintf('The parent scope "%s" does not exist, or is invalid.', $parentScope));
  216. }
  217. $this->scopes[$name] = $parentScope;
  218. $this->scopeChildren[$name] = array();
  219. while ($parentScope !== self::SCOPE_CONTAINER) {
  220. $this->scopeChildren[$parentScope][] = $name;
  221. $parentScope = $this->scopes[$parentScope];
  222. }
  223. }
  224. public function hasScope($name)
  225. {
  226. return isset($this->scopes[$name]);
  227. }
  228. public function isScopeActive($name)
  229. {
  230. return isset($this->scopedServices[$name]);
  231. }
  232. public static function camelize($id)
  233. {
  234. return strtr(ucwords(strtr($id, array('_'=>' ','.'=>'_ '))), array(' '=>''));
  235. }
  236. public static function underscore($id)
  237. {
  238. return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/','/([a-z\d])([A-Z])/'), array('\\1_\\2','\\1_\\2'), strtr($id,'_','.')));
  239. }
  240. }
  241. }
  242. namespace Symfony\Component\HttpKernel
  243. {
  244. use Symfony\Component\HttpFoundation\Request;
  245. use Symfony\Component\HttpFoundation\Response;
  246. interface HttpKernelInterface
  247. {
  248. const MASTER_REQUEST = 1;
  249. const SUB_REQUEST = 2;
  250. public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true);
  251. }
  252. }
  253. namespace Symfony\Component\HttpKernel
  254. {
  255. use Symfony\Component\DependencyInjection\ContainerInterface;
  256. use Symfony\Component\HttpKernel\HttpKernelInterface;
  257. use Symfony\Component\HttpKernel\Bundle\BundleInterface;
  258. use Symfony\Component\Config\Loader\LoaderInterface;
  259. interface KernelInterface extends HttpKernelInterface, \Serializable
  260. {
  261. public function registerBundles();
  262. public function registerContainerConfiguration(LoaderInterface $loader);
  263. public function boot();
  264. public function shutdown();
  265. public function getBundles();
  266. public function isClassInActiveBundle($class);
  267. public function getBundle($name, $first = true);
  268. public function locateResource($name, $dir = null, $first = true);
  269. public function getName();
  270. public function getEnvironment();
  271. public function isDebug();
  272. public function getRootDir();
  273. public function getContainer();
  274. public function getStartTime();
  275. public function getCacheDir();
  276. public function getLogDir();
  277. public function getCharset();
  278. }
  279. }
  280. namespace Symfony\Component\HttpKernel
  281. {
  282. use Symfony\Component\HttpFoundation\Request;
  283. use Symfony\Component\HttpFoundation\Response;
  284. interface TerminableInterface
  285. {
  286. public function terminate(Request $request, Response $response);
  287. }
  288. }
  289. namespace Symfony\Component\HttpKernel
  290. {
  291. use Symfony\Component\DependencyInjection\ContainerInterface;
  292. use Symfony\Component\DependencyInjection\ContainerBuilder;
  293. use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
  294. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
  295. use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
  296. use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
  297. use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
  298. use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
  299. use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
  300. use Symfony\Component\HttpFoundation\Request;
  301. use Symfony\Component\HttpFoundation\Response;
  302. use Symfony\Component\HttpKernel\HttpKernelInterface;
  303. use Symfony\Component\HttpKernel\Bundle\BundleInterface;
  304. use Symfony\Component\HttpKernel\Config\FileLocator;
  305. use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass;
  306. use Symfony\Component\HttpKernel\DependencyInjection\AddClassesToCachePass;
  307. use Symfony\Component\HttpKernel\Debug\ErrorHandler;
  308. use Symfony\Component\HttpKernel\Debug\ExceptionHandler;
  309. use Symfony\Component\Config\Loader\LoaderResolver;
  310. use Symfony\Component\Config\Loader\DelegatingLoader;
  311. use Symfony\Component\Config\ConfigCache;
  312. use Symfony\Component\ClassLoader\ClassCollectionLoader;
  313. use Symfony\Component\ClassLoader\DebugClassLoader;
  314. abstract class Kernel implements KernelInterface, TerminableInterface
  315. {
  316. protected $bundles;
  317. protected $bundleMap;
  318. protected $container;
  319. protected $rootDir;
  320. protected $environment;
  321. protected $debug;
  322. protected $booted;
  323. protected $name;
  324. protected $startTime;
  325. protected $errorReportingLevel;
  326. const VERSION ='2.2.8';
  327. const VERSION_ID ='20208';
  328. const MAJOR_VERSION ='2';
  329. const MINOR_VERSION ='2';
  330. const RELEASE_VERSION ='8';
  331. const EXTRA_VERSION ='';
  332. public function __construct($environment, $debug)
  333. {
  334. $this->environment = $environment;
  335. $this->debug = (Boolean) $debug;
  336. $this->booted = false;
  337. $this->rootDir = $this->getRootDir();
  338. $this->name = $this->getName();
  339. $this->bundles = array();
  340. if ($this->debug) {
  341. $this->startTime = microtime(true);
  342. }
  343. $this->init();
  344. }
  345. public function init()
  346. {
  347. ini_set('display_errors', 0);
  348. if ($this->debug) {
  349. error_reporting(-1);
  350. if (class_exists('Symfony\Component\ClassLoader\DebugClassLoader')) {
  351. DebugClassLoader::enable();
  352. }
  353. ErrorHandler::register($this->errorReportingLevel);
  354. if ('cli'!== php_sapi_name()) {
  355. ExceptionHandler::register();
  356. } else {
  357. ini_set('display_errors', 1);
  358. }
  359. }
  360. }
  361. public function __clone()
  362. {
  363. if ($this->debug) {
  364. $this->startTime = microtime(true);
  365. }
  366. $this->booted = false;
  367. $this->container = null;
  368. }
  369. public function boot()
  370. {
  371. if (true === $this->booted) {
  372. return;
  373. }
  374. $this->initializeBundles();
  375. $this->initializeContainer();
  376. foreach ($this->getBundles() as $bundle) {
  377. $bundle->setContainer($this->container);
  378. $bundle->boot();
  379. }
  380. $this->booted = true;
  381. }
  382. public function terminate(Request $request, Response $response)
  383. {
  384. if (false === $this->booted) {
  385. return;
  386. }
  387. if ($this->getHttpKernel() instanceof TerminableInterface) {
  388. $this->getHttpKernel()->terminate($request, $response);
  389. }
  390. }
  391. public function shutdown()
  392. {
  393. if (false === $this->booted) {
  394. return;
  395. }
  396. $this->booted = false;
  397. foreach ($this->getBundles() as $bundle) {
  398. $bundle->shutdown();
  399. $bundle->setContainer(null);
  400. }
  401. $this->container = null;
  402. }
  403. public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
  404. {
  405. if (false === $this->booted) {
  406. $this->boot();
  407. }
  408. return $this->getHttpKernel()->handle($request, $type, $catch);
  409. }
  410. protected function getHttpKernel()
  411. {
  412. return $this->container->get('http_kernel');
  413. }
  414. public function getBundles()
  415. {
  416. return $this->bundles;
  417. }
  418. public function isClassInActiveBundle($class)
  419. {
  420. foreach ($this->getBundles() as $bundle) {
  421. if (0 === strpos($class, $bundle->getNamespace())) {
  422. return true;
  423. }
  424. }
  425. return false;
  426. }
  427. public function getBundle($name, $first = true)
  428. {
  429. if (!isset($this->bundleMap[$name])) {
  430. throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your %s.php file?', $name, get_class($this)));
  431. }
  432. if (true === $first) {
  433. return $this->bundleMap[$name][0];
  434. }
  435. return $this->bundleMap[$name];
  436. }
  437. public function locateResource($name, $dir = null, $first = true)
  438. {
  439. if ('@'!== $name[0]) {
  440. throw new \InvalidArgumentException(sprintf('A resource name must start with @ ("%s" given).', $name));
  441. }
  442. if (false !== strpos($name,'..')) {
  443. throw new \RuntimeException(sprintf('File name "%s" contains invalid characters (..).', $name));
  444. }
  445. $bundleName = substr($name, 1);
  446. $path ='';
  447. if (false !== strpos($bundleName,'/')) {
  448. list($bundleName, $path) = explode('/', $bundleName, 2);
  449. }
  450. $isResource = 0 === strpos($path,'Resources') && null !== $dir;
  451. $overridePath = substr($path, 9);
  452. $resourceBundle = null;
  453. $bundles = $this->getBundle($bundleName, false);
  454. $files = array();
  455. foreach ($bundles as $bundle) {
  456. if ($isResource && file_exists($file = $dir.'/'.$bundle->getName().$overridePath)) {
  457. if (null !== $resourceBundle) {
  458. throw new \RuntimeException(sprintf('"%s" resource is hidden by a resource from the "%s" derived bundle. Create a "%s" file to override the bundle resource.',
  459. $file,
  460. $resourceBundle,
  461. $dir.'/'.$bundles[0]->getName().$overridePath
  462. ));
  463. }
  464. if ($first) {
  465. return $file;
  466. }
  467. $files[] = $file;
  468. }
  469. if (file_exists($file = $bundle->getPath().'/'.$path)) {
  470. if ($first && !$isResource) {
  471. return $file;
  472. }
  473. $files[] = $file;
  474. $resourceBundle = $bundle->getName();
  475. }
  476. }
  477. if (count($files) > 0) {
  478. return $first && $isResource ? $files[0] : $files;
  479. }
  480. throw new \InvalidArgumentException(sprintf('Unable to find file "%s".', $name));
  481. }
  482. public function getName()
  483. {
  484. if (null === $this->name) {
  485. $this->name = preg_replace('/[^a-zA-Z0-9_]+/','', basename($this->rootDir));
  486. }
  487. return $this->name;
  488. }
  489. public function getEnvironment()
  490. {
  491. return $this->environment;
  492. }
  493. public function isDebug()
  494. {
  495. return $this->debug;
  496. }
  497. public function getRootDir()
  498. {
  499. if (null === $this->rootDir) {
  500. $r = new \ReflectionObject($this);
  501. $this->rootDir = str_replace('\\','/', dirname($r->getFileName()));
  502. }
  503. return $this->rootDir;
  504. }
  505. public function getContainer()
  506. {
  507. return $this->container;
  508. }
  509. public function loadClassCache($name ='classes', $extension ='.php')
  510. {
  511. if (!$this->booted && is_file($this->getCacheDir().'/classes.map')) {
  512. ClassCollectionLoader::load(include($this->getCacheDir().'/classes.map'), $this->getCacheDir(), $name, $this->debug, false, $extension);
  513. }
  514. }
  515. public function setClassCache(array $classes)
  516. {
  517. file_put_contents($this->getCacheDir().'/classes.map', sprintf('<?php return %s;', var_export($classes, true)));
  518. }
  519. public function getStartTime()
  520. {
  521. return $this->debug ? $this->startTime : -INF;
  522. }
  523. public function getCacheDir()
  524. {
  525. return $this->rootDir.'/cache/'.$this->environment;
  526. }
  527. public function getLogDir()
  528. {
  529. return $this->rootDir.'/logs';
  530. }
  531. public function getCharset()
  532. {
  533. return'UTF-8';
  534. }
  535. protected function initializeBundles()
  536. {
  537. $this->bundles = array();
  538. $topMostBundles = array();
  539. $directChildren = array();
  540. foreach ($this->registerBundles() as $bundle) {
  541. $name = $bundle->getName();
  542. if (isset($this->bundles[$name])) {
  543. throw new \LogicException(sprintf('Trying to register two bundles with the same name "%s"', $name));
  544. }
  545. $this->bundles[$name] = $bundle;
  546. if ($parentName = $bundle->getParent()) {
  547. if (isset($directChildren[$parentName])) {
  548. throw new \LogicException(sprintf('Bundle "%s" is directly extended by two bundles "%s" and "%s".', $parentName, $name, $directChildren[$parentName]));
  549. }
  550. if ($parentName == $name) {
  551. throw new \LogicException(sprintf('Bundle "%s" can not extend itself.', $name));
  552. }
  553. $directChildren[$parentName] = $name;
  554. } else {
  555. $topMostBundles[$name] = $bundle;
  556. }
  557. }
  558. if (count($diff = array_values(array_diff(array_keys($directChildren), array_keys($this->bundles))))) {
  559. throw new \LogicException(sprintf('Bundle "%s" extends bundle "%s", which is not registered.', $directChildren[$diff[0]], $diff[0]));
  560. }
  561. $this->bundleMap = array();
  562. foreach ($topMostBundles as $name => $bundle) {
  563. $bundleMap = array($bundle);
  564. $hierarchy = array($name);
  565. while (isset($directChildren[$name])) {
  566. $name = $directChildren[$name];
  567. array_unshift($bundleMap, $this->bundles[$name]);
  568. $hierarchy[] = $name;
  569. }
  570. foreach ($hierarchy as $bundle) {
  571. $this->bundleMap[$bundle] = $bundleMap;
  572. array_pop($bundleMap);
  573. }
  574. }
  575. }
  576. protected function getContainerClass()
  577. {
  578. return $this->name.ucfirst($this->environment).($this->debug ?'Debug':'').'ProjectContainer';
  579. }
  580. protected function getContainerBaseClass()
  581. {
  582. return'Container';
  583. }
  584. protected function initializeContainer()
  585. {
  586. $class = $this->getContainerClass();
  587. $cache = new ConfigCache($this->getCacheDir().'/'.$class.'.php', $this->debug);
  588. $fresh = true;
  589. if (!$cache->isFresh()) {
  590. $container = $this->buildContainer();
  591. $this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());
  592. $fresh = false;
  593. }
  594. require_once $cache;
  595. $this->container = new $class();
  596. $this->container->set('kernel', $this);
  597. if (!$fresh && $this->container->has('cache_warmer')) {
  598. $this->container->get('cache_warmer')->warmUp($this->container->getParameter('kernel.cache_dir'));
  599. }
  600. }
  601. protected function getKernelParameters()
  602. {
  603. $bundles = array();
  604. foreach ($this->bundles as $name => $bundle) {
  605. $bundles[$name] = get_class($bundle);
  606. }
  607. return array_merge(
  608. array('kernel.root_dir'=> $this->rootDir,'kernel.environment'=> $this->environment,'kernel.debug'=> $this->debug,'kernel.name'=> $this->name,'kernel.cache_dir'=> $this->getCacheDir(),'kernel.logs_dir'=> $this->getLogDir(),'kernel.bundles'=> $bundles,'kernel.charset'=> $this->getCharset(),'kernel.container_class'=> $this->getContainerClass(),
  609. ),
  610. $this->getEnvParameters()
  611. );
  612. }
  613. protected function getEnvParameters()
  614. {
  615. $parameters = array();
  616. foreach ($_SERVER as $key => $value) {
  617. if (0 === strpos($key,'SYMFONY__')) {
  618. $parameters[strtolower(str_replace('__','.', substr($key, 9)))] = $value;
  619. }
  620. }
  621. return $parameters;
  622. }
  623. protected function buildContainer()
  624. {
  625. foreach (array('cache'=> $this->getCacheDir(),'logs'=> $this->getLogDir()) as $name => $dir) {
  626. if (!is_dir($dir)) {
  627. if (false === @mkdir($dir, 0777, true)) {
  628. throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n", $name, $dir));
  629. }
  630. } elseif (!is_writable($dir)) {
  631. throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n", $name, $dir));
  632. }
  633. }
  634. $container = $this->getContainerBuilder();
  635. $extensions = array();
  636. foreach ($this->bundles as $bundle) {
  637. if ($extension = $bundle->getContainerExtension()) {
  638. $container->registerExtension($extension);
  639. $extensions[] = $extension->getAlias();
  640. }
  641. if ($this->debug) {
  642. $container->addObjectResource($bundle);
  643. }
  644. }
  645. foreach ($this->bundles as $bundle) {
  646. $bundle->build($container);
  647. }
  648. $container->addObjectResource($this);
  649. $container->getCompilerPassConfig()->setMergePass(new MergeExtensionConfigurationPass($extensions));
  650. if (null !== $cont = $this->registerContainerConfiguration($this->getContainerLoader($container))) {
  651. $container->merge($cont);
  652. }
  653. $container->addCompilerPass(new AddClassesToCachePass($this));
  654. $container->compile();
  655. return $container;
  656. }
  657. protected function getContainerBuilder()
  658. {
  659. return new ContainerBuilder(new ParameterBag($this->getKernelParameters()));
  660. }
  661. protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
  662. {
  663. $dumper = new PhpDumper($container);
  664. $content = $dumper->dump(array('class'=> $class,'base_class'=> $baseClass));
  665. if (!$this->debug) {
  666. $content = self::stripComments($content);
  667. }
  668. $cache->write($content, $container->getResources());
  669. }
  670. protected function getContainerLoader(ContainerInterface $container)
  671. {
  672. $locator = new FileLocator($this);
  673. $resolver = new LoaderResolver(array(
  674. new XmlFileLoader($container, $locator),
  675. new YamlFileLoader($container, $locator),
  676. new IniFileLoader($container, $locator),
  677. new PhpFileLoader($container, $locator),
  678. new ClosureLoader($container),
  679. ));
  680. return new DelegatingLoader($resolver);
  681. }
  682. public static function stripComments($source)
  683. {
  684. if (!function_exists('token_get_all')) {
  685. return $source;
  686. }
  687. $rawChunk ='';
  688. $output ='';
  689. $tokens = token_get_all($source);
  690. for (reset($tokens); false !== $token = current($tokens); next($tokens)) {
  691. if (is_string($token)) {
  692. $rawChunk .= $token;
  693. } elseif (T_START_HEREDOC === $token[0]) {
  694. $output .= preg_replace(array('/\s+$/Sm','/\n+/S'),"\n", $rawChunk) . $token[1];
  695. do {
  696. $token = next($tokens);
  697. $output .= $token[1];
  698. } while ($token[0] !== T_END_HEREDOC);
  699. $rawChunk ='';
  700. } elseif (!in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
  701. $rawChunk .= $token[1];
  702. }
  703. }
  704. $output .= preg_replace(array('/\s+$/Sm','/\n+/S'),"\n", $rawChunk);
  705. return $output;
  706. }
  707. public function serialize()
  708. {
  709. return serialize(array($this->environment, $this->debug));
  710. }
  711. public function unserialize($data)
  712. {
  713. list($environment, $debug) = unserialize($data);
  714. $this->__construct($environment, $debug);
  715. }
  716. }
  717. }
  718. namespace Symfony\Component\ClassLoader
  719. {
  720. class ApcClassLoader
  721. {
  722. private $prefix;
  723. protected $decorated;
  724. public function __construct($prefix, $decorated)
  725. {
  726. if (!extension_loaded('apc')) {
  727. throw new \RuntimeException('Unable to use ApcClassLoader as APC is not enabled.');
  728. }
  729. if (!method_exists($decorated,'findFile')) {
  730. throw new \InvalidArgumentException('The class finder must implement a "findFile" method.');
  731. }
  732. $this->prefix = $prefix;
  733. $this->decorated = $decorated;
  734. }
  735. public function register($prepend = false)
  736. {
  737. spl_autoload_register(array($this,'loadClass'), true, $prepend);
  738. }
  739. public function unregister()
  740. {
  741. spl_autoload_unregister(array($this,'loadClass'));
  742. }
  743. public function loadClass($class)
  744. {
  745. if ($file = $this->findFile($class)) {
  746. require $file;
  747. return true;
  748. }
  749. }
  750. public function findFile($class)
  751. {
  752. if (false === $file = apc_fetch($this->prefix.$class)) {
  753. apc_store($this->prefix.$class, $file = $this->decorated->findFile($class));
  754. }
  755. return $file;
  756. }
  757. public function __call($method, $args)
  758. {
  759. return call_user_func_array(array($this->decorated, $method), $args);
  760. }
  761. }
  762. }
  763. namespace Symfony\Component\HttpKernel\Bundle
  764. {
  765. use Symfony\Component\DependencyInjection\ContainerAwareInterface;
  766. use Symfony\Component\DependencyInjection\ContainerBuilder;
  767. use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
  768. interface BundleInterface extends ContainerAwareInterface
  769. {
  770. public function boot();
  771. public function shutdown();
  772. public function build(ContainerBuilder $container);
  773. public function getContainerExtension();
  774. public function getParent();
  775. public function getName();
  776. public function getNamespace();
  777. public function getPath();
  778. }
  779. }
  780. namespace Symfony\Component\DependencyInjection
  781. {
  782. abstract class ContainerAware implements ContainerAwareInterface
  783. {
  784. protected $container;
  785. public function setContainer(ContainerInterface $container = null)
  786. {
  787. $this->container = $container;
  788. }
  789. }
  790. }
  791. namespace Symfony\Component\HttpKernel\Bundle
  792. {
  793. use Symfony\Component\DependencyInjection\ContainerAware;
  794. use Symfony\Component\DependencyInjection\ContainerBuilder;
  795. use Symfony\Component\DependencyInjection\Container;
  796. use Symfony\Component\Console\Application;
  797. use Symfony\Component\Finder\Finder;
  798. use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
  799. abstract class Bundle extends ContainerAware implements BundleInterface
  800. {
  801. protected $name;
  802. protected $reflected;
  803. protected $extension;
  804. public function boot()
  805. {
  806. }
  807. public function shutdown()
  808. {
  809. }
  810. public function build(ContainerBuilder $container)
  811. {
  812. }
  813. public function getContainerExtension()
  814. {
  815. if (null === $this->extension) {
  816. $basename = preg_replace('/Bundle$/','', $this->getName());
  817. $class = $this->getNamespace().'\\DependencyInjection\\'.$basename.'Extension';
  818. if (class_exists($class)) {
  819. $extension = new $class();
  820. $expectedAlias = Container::underscore($basename);
  821. if ($expectedAlias != $extension->getAlias()) {
  822. throw new \LogicException(sprintf('The extension alias for the default extension of a '.'bundle must be the underscored version of the '.'bundle name ("%s" instead of "%s")',
  823. $expectedAlias, $extension->getAlias()
  824. ));
  825. }
  826. $this->extension = $extension;
  827. } else {
  828. $this->extension = false;
  829. }
  830. }
  831. if ($this->extension) {
  832. return $this->extension;
  833. }
  834. }
  835. public function getNamespace()
  836. {
  837. if (null === $this->reflected) {
  838. $this->reflected = new \ReflectionObject($this);
  839. }
  840. return $this->reflected->getNamespaceName();
  841. }
  842. public function getPath()
  843. {
  844. if (null === $this->reflected) {
  845. $this->reflected = new \ReflectionObject($this);
  846. }
  847. return dirname($this->reflected->getFileName());
  848. }
  849. public function getParent()
  850. {
  851. return null;
  852. }
  853. final public function getName()
  854. {
  855. if (null !== $this->name) {
  856. return $this->name;
  857. }
  858. $name = get_class($this);
  859. $pos = strrpos($name,'\\');
  860. return $this->name = false === $pos ? $name : substr($name, $pos + 1);
  861. }
  862. public function registerCommands(Application $application)
  863. {
  864. if (!is_dir($dir = $this->getPath().'/Command')) {
  865. return;
  866. }
  867. $finder = new Finder();
  868. $finder->files()->name('*Command.php')->in($dir);
  869. $prefix = $this->getNamespace().'\\Command';
  870. foreach ($finder as $file) {
  871. $ns = $prefix;
  872. if ($relativePath = $file->getRelativePath()) {
  873. $ns .='\\'.strtr($relativePath,'/','\\');
  874. }
  875. $r = new \ReflectionClass($ns.'\\'.$file->getBasename('.php'));
  876. if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) {
  877. $application->add($r->newInstance());
  878. }
  879. }
  880. }
  881. }
  882. }
  883. namespace Symfony\Component\Config
  884. {
  885. use Symfony\Component\Config\Resource\ResourceInterface;
  886. class ConfigCache
  887. {
  888. private $debug;
  889. private $file;
  890. public function __construct($file, $debug)
  891. {
  892. $this->file = $file;
  893. $this->debug = (Boolean) $debug;
  894. }
  895. public function __toString()
  896. {
  897. return $this->file;
  898. }
  899. public function isFresh()
  900. {
  901. if (!is_file($this->file)) {
  902. return false;
  903. }
  904. if (!$this->debug) {
  905. return true;
  906. }
  907. $metadata = $this->file.'.meta';
  908. if (!is_file($metadata)) {
  909. return false;
  910. }
  911. $time = filemtime($this->file);
  912. $meta = unserialize(file_get_contents($metadata));
  913. foreach ($meta as $resource) {
  914. if (!$resource->isFresh($time)) {
  915. return false;
  916. }
  917. }
  918. return true;
  919. }
  920. public function write($content, array $metadata = null)
  921. {
  922. $dir = dirname($this->file);
  923. if (!is_dir($dir)) {
  924. if (false === @mkdir($dir, 0777, true)) {
  925. throw new \RuntimeException(sprintf('Unable to create the %s directory', $dir));
  926. }
  927. } elseif (!is_writable($dir)) {
  928. throw new \RuntimeException(sprintf('Unable to write in the %s directory', $dir));
  929. }
  930. $tmpFile = tempnam($dir, basename($this->file));
  931. if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $this->file)) {
  932. @chmod($this->file, 0666 & ~umask());
  933. } else {
  934. throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $this->file));
  935. }
  936. if (null !== $metadata && true === $this->debug) {
  937. $file = $this->file.'.meta';
  938. $tmpFile = tempnam($dir, basename($file));
  939. if (false !== @file_put_contents($tmpFile, serialize($metadata)) && @rename($tmpFile, $file)) {
  940. @chmod($file, 0666 & ~umask());
  941. }
  942. }
  943. }
  944. }
  945. }
  946. namespace Symfony\Component\HttpKernel
  947. {
  948. use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
  949. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  950. use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
  951. use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
  952. use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
  953. use Symfony\Component\HttpKernel\Event\GetResponseEvent;
  954. use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
  955. use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
  956. use Symfony\Component\HttpKernel\Event\PostResponseEvent;
  957. use Symfony\Component\HttpFoundation\Request;
  958. use Symfony\Component\HttpFoundation\Response;
  959. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  960. class HttpKernel implements HttpKernelInterface, TerminableInterface
  961. {
  962. protected $dispatcher;
  963. protected $resolver;
  964. public function __construct(EventDispatcherInterface $dispatcher, ControllerResolverInterface $resolver)
  965. {
  966. $this->dispatcher = $dispatcher;
  967. $this->resolver = $resolver;
  968. }
  969. public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
  970. {
  971. try {
  972. return $this->handleRaw($request, $type);
  973. } catch (\Exception $e) {
  974. if (false === $catch) {
  975. throw $e;
  976. }
  977. return $this->handleException($e, $request, $type);
  978. }
  979. }
  980. public function terminate(Request $request, Response $response)
  981. {
  982. $this->dispatcher->dispatch(KernelEvents::TERMINATE, new PostResponseEvent($this, $request, $response));
  983. }
  984. private function handleRaw(Request $request, $type = self::MASTER_REQUEST)
  985. {
  986. $event = new GetResponseEvent($this, $request, $type);
  987. $this->dispatcher->dispatch(KernelEvents::REQUEST, $event);
  988. if ($event->hasResponse()) {
  989. return $this->filterResponse($event->getResponse(), $request, $type);
  990. }
  991. if (false === $controller = $this->resolver->getController($request)) {
  992. throw new NotFoundHttpException(sprintf('Unable to find the controller for path "%s". Maybe you forgot to add the matching route in your routing configuration?', $request->getPathInfo()));
  993. }
  994. $event = new FilterControllerEvent($this, $controller, $request, $type);
  995. $this->dispatcher->dispatch(KernelEvents::CONTROLLER, $event);
  996. $controller = $event->getController();
  997. $arguments = $this->resolver->getArguments($request, $controller);
  998. $response = call_user_func_array($controller, $arguments);
  999. if (!$response instanceof Response) {
  1000. $event = new GetResponseForControllerResultEvent($this, $request, $type, $response);
  1001. $this->dispatcher->dispatch(KernelEvents::VIEW, $event);
  1002. if ($event->hasResponse()) {
  1003. $response = $event->getResponse();
  1004. }
  1005. if (!$response instanceof Response) {
  1006. $msg = sprintf('The controller must return a response (%s given).', $this->varToString($response));
  1007. if (null === $response) {
  1008. $msg .=' Did you forget to add a return statement somewhere in your controller?';
  1009. }
  1010. throw new \LogicException($msg);
  1011. }
  1012. }
  1013. return $this->filterResponse($response, $request, $type);
  1014. }
  1015. private function filterResponse(Response $response, Request $request, $type)
  1016. {
  1017. $event = new FilterResponseEvent($this, $request, $type, $response);
  1018. $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event);
  1019. return $event->getResponse();
  1020. }
  1021. private function handleException(\Exception $e, $request, $type)
  1022. {
  1023. $event = new GetResponseForExceptionEvent($this, $request, $type, $e);
  1024. $this->dispatcher->dispatch(KernelEvents::EXCEPTION, $event);
  1025. $e = $event->getException();
  1026. if (!$event->hasResponse()) {
  1027. throw $e;
  1028. }
  1029. $response = $event->getResponse();
  1030. if ($response->headers->has('X-Status-Code')) {
  1031. $response->setStatusCode($response->headers->get('X-Status-Code'));
  1032. $response->headers->remove('X-Status-Code');
  1033. } elseif (!$response->isClientError() && !$response->isServerError() && !$response->isRedirect()) {
  1034. if ($e instanceof HttpExceptionInterface) {
  1035. $response->setStatusCode($e->getStatusCode());
  1036. $response->headers->add($e->getHeaders());
  1037. } else {
  1038. $response->setStatusCode(500);
  1039. }
  1040. }
  1041. try {
  1042. return $this->filterResponse($response, $request, $type);
  1043. } catch (\Exception $e) {
  1044. return $response;
  1045. }
  1046. }
  1047. private function varToString($var)
  1048. {
  1049. if (is_object($var)) {
  1050. return sprintf('Object(%s)', get_class($var));
  1051. }
  1052. if (is_array($var)) {
  1053. $a = array();
  1054. foreach ($var as $k => $v) {
  1055. $a[] = sprintf('%s => %s', $k, $this->varToString($v));
  1056. }
  1057. return sprintf("Array(%s)", implode(', ', $a));
  1058. }
  1059. if (is_resource($var)) {
  1060. return sprintf('Resource(%s)', get_resource_type($var));
  1061. }
  1062. if (null === $var) {
  1063. return'null';
  1064. }
  1065. if (false === $var) {
  1066. return'false';
  1067. }
  1068. if (true === $var) {
  1069. return'true';
  1070. }
  1071. return (string) $var;
  1072. }
  1073. }
  1074. }
  1075. namespace Symfony\Component\HttpKernel\DependencyInjection
  1076. {
  1077. use Symfony\Component\HttpFoundation\Request;
  1078. use Symfony\Component\HttpKernel\HttpKernelInterface;
  1079. use Symfony\Component\HttpKernel\HttpKernel;
  1080. use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
  1081. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  1082. use Symfony\Component\DependencyInjection\ContainerInterface;
  1083. class ContainerAwareHttpKernel extends HttpKernel
  1084. {
  1085. protected $container;
  1086. public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver)
  1087. {
  1088. parent::__construct($dispatcher, $controllerResolver);
  1089. $this->container = $container;
  1090. }
  1091. public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
  1092. {
  1093. $request->headers->set('X-Php-Ob-Level', ob_get_level());
  1094. $this->container->enterScope('request');
  1095. $this->container->set('request', $request,'request');
  1096. try {
  1097. $response = parent::handle($request, $type, $catch);
  1098. } catch (\Exception $e) {
  1099. $this->container->leaveScope('request');
  1100. throw $e;
  1101. }
  1102. $this->container->leaveScope('request');
  1103. return $response;
  1104. }
  1105. }
  1106. }
  1107. namespace Symfony\Bundle\FrameworkBundle
  1108. {
  1109. use Symfony\Component\HttpFoundation\Response;
  1110. use Symfony\Component\HttpKernel\HttpKernelInterface;
  1111. use Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel;
  1112. class HttpKernel extends ContainerAwareHttpKernel
  1113. {
  1114. public function forward($controller, array $attributes = array(), array $query = array())
  1115. {
  1116. trigger_error('forward() is deprecated since version 2.2 and will be removed in 2.3.', E_USER_DEPRECATED);
  1117. $attributes['_controller'] = $controller;
  1118. $subRequest = $this->container->get('request')->duplicate($query, null, $attributes);
  1119. return $this->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
  1120. }
  1121. public function render($uri, array $options = array())
  1122. {
  1123. trigger_error('render() is deprecated since version 2.2 and will be removed in 2.3. Use Symfony\Component\HttpKernel\Fragment\FragmentHandler::render() instead.', E_USER_DEPRECATED);
  1124. $options = $this->renderer->fixOptions($options);
  1125. $strategy = isset($options['strategy']) ? $options['strategy'] :'default';
  1126. unset($options['strategy']);
  1127. $this->container->get('fragment.handler')->render($uri, $strategy, $options);
  1128. }
  1129. }
  1130. }
  1131. namespace { return $loader; }