-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
617 additions
and
617 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,132 +1,132 @@ | ||
<?php | ||
|
||
namespace Charcoal\Model; | ||
|
||
// From 'charcoal-config' | ||
use Charcoal\Config\AbstractConfig; | ||
|
||
// From 'charcoal-property' | ||
use Charcoal\Property\PropertyInterface; | ||
|
||
// From 'charcoal-core' | ||
use Charcoal\Model\MetadataInterface; | ||
|
||
/** | ||
* A basic metadata container. | ||
* | ||
* Abstract implementation of {@see \Charcoal\Model\MetadataInterface}. | ||
* | ||
* This class also implements the `ArrayAccess`, so properties can be accessed with `[]`. | ||
* The `LoadableInterface` is also implemented, mostly through `LoadableTrait`. | ||
*/ | ||
abstract class AbstractMetadata extends AbstractConfig implements | ||
MetadataInterface | ||
{ | ||
/** | ||
* Holds the default values of this configuration object. | ||
* | ||
* @var array | ||
*/ | ||
protected $defaultData = []; | ||
|
||
/** | ||
* Holds the properties of this configuration object. | ||
* | ||
* @var array | ||
*/ | ||
protected $properties = []; | ||
|
||
/** | ||
* Stores the properties, as objects, of this configuration object. | ||
* | ||
* @var PropertyInterface[] | ||
*/ | ||
protected $propertiesObjects; | ||
|
||
/** | ||
* Set the object's default values. | ||
* | ||
* @param array $defaultData An associative array. | ||
* @return self | ||
*/ | ||
public function setDefaultData(array $defaultData) | ||
{ | ||
$this->defaultData = $defaultData; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Retrieve the default values. | ||
* | ||
* @return array | ||
*/ | ||
public function defaultData() | ||
{ | ||
return $this->defaultData; | ||
} | ||
|
||
/** | ||
* Set the properties. | ||
* | ||
* @param array $properties One or more properties. | ||
* @return self | ||
*/ | ||
public function setProperties(array $properties) | ||
{ | ||
$this->properties = $properties; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Retrieve the properties. | ||
* | ||
* @return array | ||
*/ | ||
public function properties() | ||
{ | ||
return $this->properties; | ||
} | ||
|
||
/** | ||
* Retrieve the given property. | ||
* | ||
* @param string $propertyIdent The property identifier. | ||
* @return array|null | ||
*/ | ||
public function property($propertyIdent = null) | ||
{ | ||
if (isset($this->properties[$propertyIdent])) { | ||
return $this->properties[$propertyIdent]; | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* Assign an instance of {@see PropertyInterface} to the given property. | ||
* | ||
* @param string $propertyIdent The property indentifer. | ||
* @param PropertyInterface $propertyObject The property, as an object. | ||
* @return self | ||
*/ | ||
public function setPropertyObject($propertyIdent, PropertyInterface $propertyObject) | ||
{ | ||
$this->propertiesObjects[$propertyIdent] = $propertyObject; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Retrieve the given property as an object. | ||
* | ||
* @param string $propertyIdent The property (identifier) to return, as an object. | ||
* @return PropertyInterface|null | ||
*/ | ||
public function propertyObject($propertyIdent) | ||
{ | ||
if (!isset($this->propertiesObjects[$propertyIdent])) { | ||
return null; | ||
} else { | ||
return $this->propertiesObjects[$propertyIdent]; | ||
} | ||
} | ||
} | ||
<?php | ||
|
||
namespace Charcoal\Model; | ||
|
||
// From 'charcoal-config' | ||
use Charcoal\Config\AbstractConfig; | ||
|
||
// From 'charcoal-property' | ||
use Charcoal\Property\PropertyInterface; | ||
|
||
// From 'charcoal-core' | ||
use Charcoal\Model\MetadataInterface; | ||
|
||
/** | ||
* A basic metadata container. | ||
* | ||
* Abstract implementation of {@see \Charcoal\Model\MetadataInterface}. | ||
* | ||
* This class also implements the `ArrayAccess`, so properties can be accessed with `[]`. | ||
* The `LoadableInterface` is also implemented, mostly through `LoadableTrait`. | ||
*/ | ||
abstract class AbstractMetadata extends AbstractConfig implements | ||
MetadataInterface | ||
{ | ||
/** | ||
* Holds the default values of this configuration object. | ||
* | ||
* @var array | ||
*/ | ||
protected $defaultData = []; | ||
|
||
/** | ||
* Holds the properties of this configuration object. | ||
* | ||
* @var array | ||
*/ | ||
protected $properties = []; | ||
|
||
/** | ||
* Stores the properties, as objects, of this configuration object. | ||
* | ||
* @var PropertyInterface[] | ||
*/ | ||
protected $propertiesObjects; | ||
|
||
/** | ||
* Set the object's default values. | ||
* | ||
* @param array $defaultData An associative array. | ||
* @return self | ||
*/ | ||
public function setDefaultData(array $defaultData) | ||
{ | ||
$this->defaultData = $defaultData; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Retrieve the default values. | ||
* | ||
* @return array | ||
*/ | ||
public function defaultData() | ||
{ | ||
return $this->defaultData; | ||
} | ||
|
||
/** | ||
* Set the properties. | ||
* | ||
* @param array $properties One or more properties. | ||
* @return self | ||
*/ | ||
public function setProperties(array $properties) | ||
{ | ||
$this->properties = $properties; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Retrieve the properties. | ||
* | ||
* @return array | ||
*/ | ||
public function properties() | ||
{ | ||
return $this->properties; | ||
} | ||
|
||
/** | ||
* Retrieve the given property. | ||
* | ||
* @param string $propertyIdent The property identifier. | ||
* @return array|null | ||
*/ | ||
public function property($propertyIdent = null) | ||
{ | ||
if (isset($this->properties[$propertyIdent])) { | ||
return $this->properties[$propertyIdent]; | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
/** | ||
* Assign an instance of {@see PropertyInterface} to the given property. | ||
* | ||
* @param string $propertyIdent The property indentifer. | ||
* @param PropertyInterface $propertyObject The property, as an object. | ||
* @return self | ||
*/ | ||
public function setPropertyObject($propertyIdent, PropertyInterface $propertyObject) | ||
{ | ||
$this->propertiesObjects[$propertyIdent] = $propertyObject; | ||
return $this; | ||
} | ||
|
||
/** | ||
* Retrieve the given property as an object. | ||
* | ||
* @param string $propertyIdent The property (identifier) to return, as an object. | ||
* @return PropertyInterface|null | ||
*/ | ||
public function propertyObject($propertyIdent) | ||
{ | ||
if (!isset($this->propertiesObjects[$propertyIdent])) { | ||
return null; | ||
} else { | ||
return $this->propertiesObjects[$propertyIdent]; | ||
} | ||
} | ||
} |
Oops, something went wrong.