Class luya\web\jsonld\Article
Inheritance | luya\web\jsonld\Article » luya\web\jsonld\BaseThing » yii\base\BaseObject |
---|---|
Implements | luya\web\jsonld\ArticleInterface, luya\web\jsonld\ThingInterface, yii\base\Arrayable, yii\base\Configurable |
Uses Traits | luya\web\jsonld\ArticleTrait, luya\web\jsonld\ThingTrait, yii\base\ArrayableTrait |
Available since version | 1.0.1 |
Source Code | https://github.com/luyadev/luya/blob/master/core/web/jsonld/Article.php |
JsonLd - Article
An article, such as a news article or piece of investigative report. Newspapers and magazines have articles of many different types and this is intended to cover them all.
See also http://schema.org/Article.
Public Properties
Public Methods
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\BaseObject |
__construct() | Constructor. | yii\base\BaseObject |
__get() | Returns the value of an object property. | yii\base\BaseObject |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\BaseObject |
__set() | Sets value of an object property. | yii\base\BaseObject |
__unset() | Sets an object property to null. | yii\base\BaseObject |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\BaseObject |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\BaseObject |
className() | Returns the fully qualified name of this class. | yii\base\BaseObject |
extraFields() | Returns the list of fields that can be expanded further and returned by toArray(). | yii\base\ArrayableTrait |
fields() | Returns the list of fields that should be returned by default by toArray() when no specific fields are specified. | luya\web\jsonld\BaseThing |
getAdditionalType() | luya\web\jsonld\ThingTrait | |
getAlternateName() | luya\web\jsonld\ThingTrait | |
getArticleBody() | luya\web\jsonld\ArticleTrait | |
getArticleSection() | luya\web\jsonld\ArticleTrait | |
getDescription() | luya\web\jsonld\ThingTrait | |
getDisambiguatingDescription() | luya\web\jsonld\ThingTrait | |
getIdentifier() | luya\web\jsonld\ThingTrait | |
getImage() | luya\web\jsonld\ThingTrait | |
getMainEntityOfPage() | luya\web\jsonld\ThingTrait | |
getName() | luya\web\jsonld\ThingTrait | |
getOffers() | Get Offer | luya\web\jsonld\ThingTrait |
getPageEnd() | luya\web\jsonld\ArticleTrait | |
getPageStart() | luya\web\jsonld\ArticleTrait | |
getPagination() | luya\web\jsonld\ArticleTrait | |
getSameAs() | luya\web\jsonld\ThingTrait | |
getSubjectOf() | luya\web\jsonld\ThingTrait | |
getUrl() | luya\web\jsonld\ThingTrait | |
getWordCount() | luya\web\jsonld\ArticleTrait | |
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\BaseObject |
hasProperty() | Returns a value indicating whether a property is defined. | yii\base\BaseObject |
init() | Initializes the object. | yii\base\BaseObject |
resolveGetterMethods() | Find all getter methods. | luya\web\jsonld\BaseThing |
setAdditionalType() | An additional type for the item, typically used for adding more specific types from external vocabularies in microdata syntax. | luya\web\jsonld\ThingTrait |
setAlternateName() | An alias for the item | luya\web\jsonld\ThingTrait |
setArticleBody() | The actual body of the article. | luya\web\jsonld\ArticleTrait |
setArticleSection() | Articles may belong to one or more 'sections' in a magazine or newspaper, such as Sports, Lifestyle, etc. | luya\web\jsonld\ArticleTrait |
setDescription() | A description of the item. | luya\web\jsonld\ThingTrait |
setDisambiguatingDescription() | A sub property of description. A short description of the item used to disambiguate from other, similar items. | luya\web\jsonld\ThingTrait |
setIdentifier() | The identifier property represents any kind of identifier for any kind of Thing, such as ISBNs, GTIN codes, UUIDs etc. Schema.org provides dedicated properties for representing many of these, either as textual strings or as URL (URI) links. See background notes for more details. | luya\web\jsonld\ThingTrait |
setImage() | An image of the item. | luya\web\jsonld\ThingTrait |
setMainEntityOfPage() | Indicates a page (or other CreativeWork) for which this thing is the main entity being described. | luya\web\jsonld\ThingTrait |
setName() | The name of the item. | luya\web\jsonld\ThingTrait |
setOffers() | Set Offer | luya\web\jsonld\ThingTrait |
setPageEnd() | The page on which the work ends; for example "138" or "xvi". | luya\web\jsonld\ArticleTrait |
setPageStart() | The page on which the work starts; for example "135" or "xiii". | luya\web\jsonld\ArticleTrait |
setPagination() | Any description of pages that is not separated into pageStart and pageEnd; for example, "1-6, 9, 55" or "10-12, 46-49". | luya\web\jsonld\ArticleTrait |
setSameAs() | URL of a reference Web page that unambiguously indicates the item's identity. | luya\web\jsonld\ThingTrait |
setSubjectOf() | A CreativeWork or Event about this Thing. | luya\web\jsonld\ThingTrait |
setUrl() | URL of the item. | luya\web\jsonld\ThingTrait |
setWordCount() | The number of words in the text of the Article. | luya\web\jsonld\ArticleTrait |
toArray() | Converts the object into an array. | luya\web\jsonld\BaseThing |
typeDefintion() | Contains the jsonLd definton @type value if not null or false. | luya\web\jsonld\Article |
Protected Methods
Method | Description | Defined By |
---|---|---|
extractFieldsFor() | Extract nested fields from a fields collection for a given root field Nested fields are separated with dots (.). e.g: "item.id" The previous example would extract "id". | yii\base\ArrayableTrait |
extractRootFields() | Extracts the root field names from nested fields. | yii\base\ArrayableTrait |
resolveFields() | Determines which fields can be returned by toArray(). | yii\base\ArrayableTrait |
Method Details
Defined in: yii\base\BaseObject::__call()
Calls the named method which is not a class method.
Do not call this method directly as it is a PHP magic method that will be implicitly called when an unknown method is being invoked.
public mixed __call ( $name, $params ) | ||
$name | string |
The method name |
$params | array |
Method parameters |
return | mixed |
The method return value |
---|---|---|
throws | yii\base\UnknownMethodException |
when calling unknown method |
public function __call($name, $params)
{
throw new UnknownMethodException('Calling unknown method: ' . get_class($this) . "::$name()");
}
Defined in: yii\base\BaseObject::__construct()
Constructor.
The default implementation does two things:
- Initializes the object with the given configuration
$config
. - Call init().
If this method is overridden in a child class, it is recommended that
- the last parameter of the constructor is a configuration array, like
$config
here. - call the parent implementation at the end of the constructor.
public void __construct ( $config = [] ) | ||
$config | array |
Name-value pairs that will be used to initialize the object properties |
public function __construct($config = [])
{
if (!empty($config)) {
Yii::configure($this, $config);
}
$this->init();
}
Defined in: yii\base\BaseObject::__get()
Returns the value of an object property.
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing $value = $object->property;
.
See also __set().
public mixed __get ( $name ) | ||
$name | string |
The property name |
return | mixed |
The property value |
---|---|---|
throws | yii\base\UnknownPropertyException |
if the property is not defined |
throws | yii\base\InvalidCallException |
if the property is write-only |
public function __get($name)
{
$getter = 'get' . $name;
if (method_exists($this, $getter)) {
return $this->$getter();
} elseif (method_exists($this, 'set' . $name)) {
throw new InvalidCallException('Getting write-only property: ' . get_class($this) . '::' . $name);
}
throw new UnknownPropertyException('Getting unknown property: ' . get_class($this) . '::' . $name);
}
Defined in: yii\base\BaseObject::__isset()
Checks if a property is set, i.e. defined and not null.
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing isset($object->property)
.
Note that if the property is not defined, false will be returned.
public boolean __isset ( $name ) | ||
$name | string |
The property name or the event name |
return | boolean |
Whether the named property is set (not null). |
---|
public function __isset($name)
{
$getter = 'get' . $name;
if (method_exists($this, $getter)) {
return $this->$getter() !== null;
}
return false;
}
Defined in: yii\base\BaseObject::__set()
Sets value of an object property.
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing $object->property = $value;
.
See also __get().
public void __set ( $name, $value ) | ||
$name | string |
The property name or the event name |
$value | mixed |
The property value |
throws | yii\base\UnknownPropertyException |
if the property is not defined |
---|---|---|
throws | yii\base\InvalidCallException |
if the property is read-only |
public function __set($name, $value)
{
$setter = 'set' . $name;
if (method_exists($this, $setter)) {
$this->$setter($value);
} elseif (method_exists($this, 'get' . $name)) {
throw new InvalidCallException('Setting read-only property: ' . get_class($this) . '::' . $name);
} else {
throw new UnknownPropertyException('Setting unknown property: ' . get_class($this) . '::' . $name);
}
}
Defined in: yii\base\BaseObject::__unset()
Sets an object property to null.
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing unset($object->property)
.
Note that if the property is not defined, this method will do nothing. If the property is read-only, it will throw an exception.
public void __unset ( $name ) | ||
$name | string |
The property name |
throws | yii\base\InvalidCallException |
if the property is read only. |
---|
public function __unset($name)
{
$setter = 'set' . $name;
if (method_exists($this, $setter)) {
$this->$setter(null);
} elseif (method_exists($this, 'get' . $name)) {
throw new InvalidCallException('Unsetting read-only property: ' . get_class($this) . '::' . $name);
}
}
Defined in: yii\base\BaseObject::canGetProperty()
Returns a value indicating whether a property can be read.
A property is readable if:
- the class has a getter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
See also canSetProperty().
public boolean canGetProperty ( $name, $checkVars = true ) | ||
$name | string |
The property name |
$checkVars | boolean |
Whether to treat member variables as properties |
return | boolean |
Whether the property can be read |
---|
public function canGetProperty($name, $checkVars = true)
{
return method_exists($this, 'get' . $name) || $checkVars && property_exists($this, $name);
}
Defined in: yii\base\BaseObject::canSetProperty()
Returns a value indicating whether a property can be set.
A property is writable if:
- the class has a setter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
See also canGetProperty().
public boolean canSetProperty ( $name, $checkVars = true ) | ||
$name | string |
The property name |
$checkVars | boolean |
Whether to treat member variables as properties |
return | boolean |
Whether the property can be written |
---|
public function canSetProperty($name, $checkVars = true)
{
return method_exists($this, 'set' . $name) || $checkVars && property_exists($this, $name);
}
::class
instead.
Defined in: yii\base\BaseObject::className()
Returns the fully qualified name of this class.
public static string className ( ) | ||
return | string |
The fully qualified name of this class. |
---|
public static function className()
{
return get_called_class();
}
Defined in: yii\base\ArrayableTrait::extraFields()
Returns the list of fields that can be expanded further and returned by toArray().
This method is similar to fields() except that the list of fields returned by this method are not returned by default by toArray(). Only when field names to be expanded are explicitly specified when calling toArray(), will their values be exported.
The default implementation returns an empty array.
You may override this method to return a list of expandable fields based on some context information (e.g. the current application user).
See also:
public array extraFields ( ) | ||
return | array |
The list of expandable field names or field definitions. Please refer to fields() on the format of the return value. |
---|
public function extraFields()
{
return [];
}
Defined in: yii\base\ArrayableTrait::extractFieldsFor()
Extract nested fields from a fields collection for a given root field Nested fields are separated with dots (.). e.g: "item.id" The previous example would extract "id".
protected array extractFieldsFor ( array $fields, $rootField ) | ||
$fields | array |
The fields requested for extraction |
$rootField | string |
The root field for which we want to extract the nested fields |
return | array |
Nested fields extracted for the given field |
---|
protected function extractFieldsFor(array $fields, $rootField)
{
$result = [];
foreach ($fields as $field) {
if (0 === strpos($field, "{$rootField}.")) {
$result[] = preg_replace('/^' . preg_quote($rootField, '/') . '\./i', '', $field);
}
}
return array_unique($result);
}
Defined in: yii\base\ArrayableTrait::extractRootFields()
Extracts the root field names from nested fields.
Nested fields are separated with dots (.). e.g: "item.id" The previous example would extract "item".
protected array extractRootFields ( array $fields ) | ||
$fields | array |
The fields requested for extraction |
return | array |
Root fields extracted from the given nested fields |
---|
protected function extractRootFields(array $fields)
{
$result = [];
foreach ($fields as $field) {
$result[] = current(explode('.', $field, 2));
}
if (in_array('*', $result, true)) {
$result = [];
}
return array_unique($result);
}
Defined in: luya\web\jsonld\BaseThing::fields()
Returns the list of fields that should be returned by default by toArray() when no specific fields are specified.
A field is a named element in the returned array by toArray().
This method should return an array of field names or field definitions. If the former, the field name will be treated as an object property name whose value will be used as the field value. If the latter, the array key should be the field name while the array value should be the corresponding field definition which can be either an object property name or a PHP callable returning the corresponding field value. The signature of the callable should be:
function ($model, $field) {
// return field value
}
For example, the following code declares four fields:
email
: the field name is the same as the property nameemail
;firstName
andlastName
: the field names arefirstName
andlastName
, and their values are obtained from thefirst_name
andlast_name
properties;fullName
: the field name isfullName
. Its value is obtained by concatenatingfirst_name
andlast_name
.
return [
'email',
'firstName' => 'first_name',
'lastName' => 'last_name',
'fullName' => function ($model) {
return $model->first_name . ' ' . $model->last_name;
},
];
public array fields ( ) | ||
return | array |
The list of field names or field definitions. |
---|
public function fields()
{
return $this->resolveGetterMethods();
}
Defined in: luya\web\jsonld\ThingTrait::getAdditionalType()
public string getAdditionalType ( ) |
public function getAdditionalType()
{
return $this->_additionalType;
}
Defined in: luya\web\jsonld\ThingTrait::getAlternateName()
public string getAlternateName ( ) |
public function getAlternateName()
{
return $this->_alternateName;
}
Defined in: luya\web\jsonld\ArticleTrait::getArticleBody()
public string getArticleBody ( ) |
public function getArticleBody()
{
return $this->_articleBody;
}
public string getArticleSection ( ) |
public function getArticleSection()
{
return $this->_articleSection;
}
Defined in: luya\web\jsonld\ThingTrait::getDescription()
public string getDescription ( ) |
public function getDescription()
{
return $this->_description;
}
public string getDisambiguatingDescription ( ) |
public function getDisambiguatingDescription()
{
return $this->_disambiguatingDescription;
}
Defined in: luya\web\jsonld\ThingTrait::getIdentifier()
public luya\web\jsonld\PropertyValue getIdentifier ( ) |
public function getIdentifier()
{
return $this->_identifier;
}
Defined in: luya\web\jsonld\ThingTrait::getImage()
public luya\web\jsonld\ImageObject getImage ( ) |
public function getImage()
{
return $this->_image;
}
public luya\web\jsonld\CreativeWork getMainEntityOfPage ( ) |
public function getMainEntityOfPage()
{
return $this->_mainEntityOfPage;
}
Defined in: luya\web\jsonld\ThingTrait::getName()
public string getName ( ) |
public function getName()
{
return $this->_name;
}
Defined in: luya\web\jsonld\ThingTrait::getOffers()
Get Offer
public luya\web\jsonld\Offer getOffers ( ) |
public function getOffers()
{
return $this->_offers;
}
Defined in: luya\web\jsonld\ArticleTrait::getPageEnd()
public integer|string getPageEnd ( ) |
public function getPageEnd()
{
return $this->_pageEnd;
}
Defined in: luya\web\jsonld\ArticleTrait::getPageStart()
public integer|string getPageStart ( ) |
public function getPageStart()
{
return $this->_pageStart;
}
Defined in: luya\web\jsonld\ArticleTrait::getPagination()
public string getPagination ( ) |
public function getPagination()
{
return $this->_pagination;
}
Defined in: luya\web\jsonld\ThingTrait::getSameAs()
public string getSameAs ( ) |
public function getSameAs()
{
return $this->_sameAs;
}
Defined in: luya\web\jsonld\ThingTrait::getSubjectOf()
public luya\web\jsonld\CreativeWork|luya\web\jsonld\Event getSubjectOf ( ) |
public function getSubjectOf()
{
return $this->_subjectOf;
}
Defined in: luya\web\jsonld\ThingTrait::getUrl()
public string getUrl ( ) |
public function getUrl()
{
return $this->_url;
}
Defined in: luya\web\jsonld\ArticleTrait::getWordCount()
public integer getWordCount ( ) |
public function getWordCount()
{
return $this->_wordCount;
}
Defined in: yii\base\BaseObject::hasMethod()
Returns a value indicating whether a method is defined.
The default implementation is a call to php function method_exists()
.
You may override this method when you implemented the php magic method __call()
.
public boolean hasMethod ( $name ) | ||
$name | string |
The method name |
return | boolean |
Whether the method is defined |
---|
public function hasMethod($name)
{
return method_exists($this, $name);
}
Defined in: yii\base\BaseObject::hasProperty()
Returns a value indicating whether a property is defined.
A property is defined if:
- the class has a getter or setter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
See also:
public boolean hasProperty ( $name, $checkVars = true ) | ||
$name | string |
The property name |
$checkVars | boolean |
Whether to treat member variables as properties |
return | boolean |
Whether the property is defined |
---|
public function hasProperty($name, $checkVars = true)
{
return $this->canGetProperty($name, $checkVars) || $this->canSetProperty($name, false);
}
Defined in: yii\base\BaseObject::init()
Initializes the object.
This method is invoked at the end of the constructor after the object is initialized with the given configuration.
public void init ( ) |
public function init()
{
}
Defined in: yii\base\ArrayableTrait::resolveFields()
Determines which fields can be returned by toArray().
This method will first extract the root fields from the given fields. Then it will check the requested root fields against those declared in fields() and extraFields() to determine which fields can be returned.
protected array resolveFields ( array $fields, array $expand ) | ||
$fields | array |
The fields being requested for exporting |
$expand | array |
The additional fields being requested for exporting |
return | array |
The list of fields to be exported. The array keys are the field names, and the array values are the corresponding object property names or PHP callables returning the field values. |
---|
protected function resolveFields(array $fields, array $expand)
{
$fields = $this->extractRootFields($fields);
$expand = $this->extractRootFields($expand);
$result = [];
foreach ($this->fields() as $field => $definition) {
if (is_int($field)) {
$field = $definition;
}
if (empty($fields) || in_array($field, $fields, true)) {
$result[$field] = $definition;
}
}
if (empty($expand)) {
return $result;
}
foreach ($this->extraFields() as $field => $definition) {
if (is_int($field)) {
$field = $definition;
}
if (in_array($field, $expand, true)) {
$result[$field] = $definition;
}
}
return $result;
}
Defined in: luya\web\jsonld\BaseThing::resolveGetterMethods()
Find all getter methods.
public array resolveGetterMethods ( ) |
public function resolveGetterMethods()
{
$resolved = [];
$methods = get_class_methods($this);
if (!$methods) {
return [];
}
foreach ($methods as $method) {
if (StringHelper::startsWith($method, 'get', true)) {
$resolved[] = lcfirst(StringHelper::replaceFirst('get', '', $method));
}
}
asort($resolved);
return $resolved;
}
Defined in: luya\web\jsonld\ThingTrait::setAdditionalType()
An additional type for the item, typically used for adding more specific types from external vocabularies in microdata syntax.
This is a relationship between something and a class that the thing is in.
public static setAdditionalType ( luya\web\jsonld\UrlValue $additionalType ) | ||
$additionalType | string |
public function setAdditionalType(UrlValue $additionalType)
{
$this->_additionalType = $additionalType->getValue();
return $this;
}
Defined in: luya\web\jsonld\ThingTrait::setAlternateName()
An alias for the item
public static setAlternateName ( $alternateName ) | ||
$alternateName | string |
public function setAlternateName($alternateName)
{
$this->_alternateName = $alternateName;
return $this;
}
Defined in: luya\web\jsonld\ArticleTrait::setArticleBody()
The actual body of the article.
public static setArticleBody ( $articleBody ) | ||
$articleBody | string |
public function setArticleBody($articleBody)
{
$this->_articleBody = $articleBody;
return $this;
}
Defined in: luya\web\jsonld\ArticleTrait::setArticleSection()
Articles may belong to one or more 'sections' in a magazine or newspaper, such as Sports, Lifestyle, etc.
public static setArticleSection ( $articleSection ) | ||
$articleSection | string |
public function setArticleSection($articleSection)
{
$this->_articleSection = $articleSection;
return $this;
}
Defined in: luya\web\jsonld\ThingTrait::setDescription()
A description of the item.
public static setDescription ( $description ) | ||
$description | string |
public function setDescription($description)
{
$this->_description = $description;
return $this;
}
Defined in: luya\web\jsonld\ThingTrait::setDisambiguatingDescription()
A sub property of description. A short description of the item used to disambiguate from other, similar items.
Information from other properties (in particular, name) may be necessary for the description to be useful for disambiguation.
public static setDisambiguatingDescription ( $disambiguatingDescription ) | ||
$disambiguatingDescription | string |
public function setDisambiguatingDescription($disambiguatingDescription)
{
$this->_disambiguatingDescription = $disambiguatingDescription;
return $this;
}
Defined in: luya\web\jsonld\ThingTrait::setIdentifier()
The identifier property represents any kind of identifier for any kind of Thing, such as ISBNs, GTIN codes, UUIDs etc. Schema.org provides dedicated properties for representing many of these, either as textual strings or as URL (URI) links. See background notes for more details.
public static setIdentifier ( luya\web\jsonld\PropertyValue $identifier ) | ||
$identifier | luya\web\jsonld\PropertyValue |
public function setIdentifier(PropertyValue $identifier)
{
$this->_identifier = $identifier;
return $this;
}
Defined in: luya\web\jsonld\ThingTrait::setImage()
An image of the item.
This can be a URL or a fully described ImageObject.
public static setImage ( luya\web\jsonld\ImageObject $image ) | ||
$image | luya\web\jsonld\ImageObject |
public function setImage(ImageObject $image)
{
$this->_image = $image;
return $this;
}
Defined in: luya\web\jsonld\ThingTrait::setMainEntityOfPage()
Indicates a page (or other CreativeWork) for which this thing is the main entity being described.
Inverse property: mainEntity.
public static setMainEntityOfPage ( luya\web\jsonld\CreativeWork $mainEntityOfPage ) | ||
$mainEntityOfPage | luya\web\jsonld\CreativeWork |
public function setMainEntityOfPage(CreativeWork $mainEntityOfPage)
{
$this->_mainEntityOfPage = $mainEntityOfPage;
return $this;
}
Defined in: luya\web\jsonld\ThingTrait::setName()
The name of the item.
public static setName ( $name ) | ||
$name | string |
public function setName($name)
{
$this->_name = $name;
return $this;
}
Defined in: luya\web\jsonld\ThingTrait::setOffers()
Set Offer
public static setOffers ( luya\web\jsonld\Offer $offers ) | ||
$offers |
public function setOffers(Offer $offers)
{
$this->_offers = $offers;
return $this;
}
Defined in: luya\web\jsonld\ArticleTrait::setPageEnd()
The page on which the work ends; for example "138" or "xvi".
public static setPageEnd ( $pageEnd ) | ||
$pageEnd | integer|string |
public function setPageEnd($pageEnd)
{
$this->_pageEnd = $pageEnd;
return $this;
}
Defined in: luya\web\jsonld\ArticleTrait::setPageStart()
The page on which the work starts; for example "135" or "xiii".
public static setPageStart ( $pageStart ) | ||
$pageStart | integer|string |
public function setPageStart($pageStart)
{
$this->_pageStart = $pageStart;
return $this;
}
Defined in: luya\web\jsonld\ArticleTrait::setPagination()
Any description of pages that is not separated into pageStart and pageEnd; for example, "1-6, 9, 55" or "10-12, 46-49".
public static setPagination ( $pagination ) | ||
$pagination | string |
public function setPagination($pagination)
{
$this->_pagination = $pagination;
return $this;
}
Defined in: luya\web\jsonld\ThingTrait::setSameAs()
URL of a reference Web page that unambiguously indicates the item's identity.
E.g. the URL of the item's Wikipedia page, Wikidata entry, or official website.
public static setSameAs ( luya\web\jsonld\UrlValue $sameAs ) | ||
$sameAs | luya\web\jsonld\UrlValue |
public function setSameAs(UrlValue $sameAs)
{
$this->_sameAs = $sameAs->getValue();
return $this;
}
Defined in: luya\web\jsonld\ThingTrait::setSubjectOf()
A CreativeWork or Event about this Thing.
Inverse property: about.
public static setSubjectOf ( $subjectOf ) | ||
$subjectOf | luya\web\jsonld\CreativeWork|luya\web\jsonld\Event |
public function setSubjectOf($subjectOf)
{
$this->_subjectOf = $subjectOf;
return $this;
}
Defined in: luya\web\jsonld\ThingTrait::setUrl()
URL of the item.
public static setUrl ( luya\web\jsonld\UrlValue $url ) | ||
$url | luya\web\jsonld\UrlValue |
public function setUrl(UrlValue $url)
{
$this->_url = $url->getValue();
return $this;
}
Defined in: luya\web\jsonld\ArticleTrait::setWordCount()
The number of words in the text of the Article.
public static setWordCount ( $wordCount ) | ||
$wordCount | integer |
public function setWordCount($wordCount)
{
$this->_wordCount = $wordCount;
return $this;
}
Defined in: luya\web\jsonld\BaseThing::toArray()
Converts the object into an array.
public array toArray ( array $fields = [], array $expand = [], $recursive = true ) | ||
$fields | array |
The fields that the output array should contain. Fields not specified in fields() will be ignored. If this parameter is empty, all fields as specified in fields() will be returned. |
$expand | array |
The additional fields that the output array should contain. Fields not specified in extraFields() will be ignored. If this parameter is empty, no extra fields will be returned. |
$recursive | boolean |
Whether to recursively return array representation of embedded objects. |
return | array |
The array representation of the object |
---|
public function toArray(array $fields = [], array $expand = [], $recursive = true)
{
$array = $this->removeEmptyValues($this->internalToArray($fields, $expand, $recursive));
if ($this->typeDefintion()) {
$array['@type'] = $this->typeDefintion();
}
return $array;
}
Contains the jsonLd definton @type value if not null or false.
public boolean|string typeDefintion ( ) | ||
return | boolean|string |
Generates the @type field. |
---|
public function typeDefintion()
{
return 'Article';
}