-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a value object for a component record
- Loading branch information
Michael Babker
committed
Feb 18, 2017
1 parent
40b3a1e
commit 863ec06
Showing
2 changed files
with
148 additions
and
11 deletions.
There are no files selected for viewing
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,142 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Libraries | ||
* @subpackage Component | ||
* | ||
* @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('JPATH_PLATFORM') or die; | ||
|
||
use Joomla\Registry\Registry; | ||
|
||
/** | ||
* Object representing a component extension record | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
class JComponentRecord extends JObject | ||
{ | ||
/** | ||
* Primary key | ||
* | ||
* @var integer | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public $id; | ||
|
||
/** | ||
* The component name | ||
* | ||
* @var integer | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public $option; | ||
|
||
/** | ||
* The component parameters | ||
* | ||
* @var string|Registry | ||
* @since __DEPLOY_VERSION__ | ||
* @note This field is protected to require reading this field to proxy through the getter to convert the params to a Registry instance | ||
*/ | ||
protected $params; | ||
|
||
/** | ||
* Indicates if this component is enabled | ||
* | ||
* @var integer | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public $enabled; | ||
|
||
/** | ||
* Class constructor | ||
* | ||
* @param array $data The menu item data to load | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function __construct($data = array()) | ||
{ | ||
foreach ((array) $data as $key => $value) | ||
{ | ||
$this->$key = $value; | ||
} | ||
} | ||
|
||
/** | ||
* Method to get certain otherwise inaccessible properties from the form field object. | ||
* | ||
* @param string $name The property name for which to the the value. | ||
* | ||
* @return mixed The property value or null. | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
* @deprecated 4.0 Access the item parameters through the `getParams()` method | ||
*/ | ||
public function __get($name) | ||
{ | ||
if ($name === 'params') | ||
{ | ||
return $this->getParams(); | ||
} | ||
|
||
return $this->get($name); | ||
} | ||
|
||
/** | ||
* Method to set certain otherwise inaccessible properties of the form field object. | ||
* | ||
* @param string $name The property name for which to the the value. | ||
* @param mixed $value The value of the property. | ||
* | ||
* @return void | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
* @deprecated 4.0 Set the item parameters through the `setParams()` method | ||
*/ | ||
public function __set($name, $value) | ||
{ | ||
if ($name === 'params') | ||
{ | ||
$this->setParams($value); | ||
|
||
return; | ||
} | ||
|
||
$this->set($name, $value); | ||
} | ||
|
||
/** | ||
* Returns the menu item parameters | ||
* | ||
* @return Registry | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function getParams() | ||
{ | ||
if (!($this->params instanceof Registry)) | ||
{ | ||
$this->params = new Registry($this->params); | ||
} | ||
|
||
return $this->params; | ||
} | ||
|
||
/** | ||
* Sets the menu item parameters | ||
* | ||
* @param Registry|string $params The data to be stored as the parameters | ||
* | ||
* @return void | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
public function setParams($params) | ||
{ | ||
$this->params = $params; | ||
} | ||
} |