-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move component categories helper to services
- Loading branch information
Showing
10 changed files
with
350 additions
and
72 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
administrator/components/com_content/services/services.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Administrator | ||
* @subpackage com_content | ||
* | ||
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
|
||
$container->share( | ||
'ContentContainer', | ||
function (\Joomla\DI\Container $parent) | ||
{ | ||
$container = new \Joomla\CMS\Component\ComponentContainer($parent); | ||
$container->registerServiceProvider( | ||
new \Joomla\CMS\Component\Service\Provider\Categories(['table' => '#__content', 'extension' => 'com_content']) | ||
); | ||
|
||
return $container; | ||
}, | ||
true | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* Joomla! Content Management System | ||
* | ||
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
namespace Joomla\CMS\Component; | ||
|
||
defined('JPATH_PLATFORM') or die; | ||
|
||
use Joomla\CMS\Categories\Categories; | ||
use Joomla\DI\Container; | ||
use Psr\Container\ContainerInterface; | ||
|
||
/** | ||
* Access to component specific services. | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
class ComponentContainer extends Container implements ComponentContainerInterface | ||
{ | ||
/** | ||
* Returns the category service. If the service is not available | ||
* null is returned. | ||
* | ||
* @param string $section The section | ||
* | ||
* @return Categories|null | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function getCategories($section = ''): Categories | ||
{ | ||
$serviceName = 'categories'; | ||
|
||
if ($section) | ||
{ | ||
$serviceName .= '.' .strtolower($section); | ||
} | ||
|
||
if (!$this->has($serviceName)) | ||
{ | ||
return null; | ||
} | ||
|
||
return $this->get($serviceName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* Joomla! Content Management System | ||
* | ||
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
namespace Joomla\CMS\Component; | ||
|
||
defined('JPATH_PLATFORM') or die; | ||
|
||
use Joomla\CMS\Categories\Categories; | ||
|
||
/** | ||
* Access to component specific services. | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
interface ComponentContainerInterface | ||
{ | ||
/** | ||
* Returns the category service. If the service is not available | ||
* null is returned. | ||
* | ||
* @param string $section The section | ||
* | ||
* @return Categories|null | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function getCategories($section = ''): Categories; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.