Skip to content

Base LocalBusiness type on Organization and Place type #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions src/ContextTypes/LocalBusiness.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,34 @@

namespace JsonLd\ContextTypes;

class LocalBusiness extends AbstractContext
class LocalBusiness extends Organization
{
/**
* Property structure
*
* @var array
*/
protected $structure = [
'name' => null,
'description' => null,
'image' => null,
'telephone' => null,
'email' => null,
protected $extendedStructure = [
'openingHours' => null,
'address' => PostalAddress::class,
'geo' => GeoCoordinates::class,
'review' => Review::class,
'aggregateRating' => AggregateRating::class,
'url' => null,
'priceRange' => null,
'areaServed' => null,
'hasMap' => null,
];

/**
* Constructor. Merges extendedStructure up
*
* @param array $attributes
* @param array $extendedStructure
*/
public function __construct(array $attributes, array $extendedStructure = [])
{
$place = new Place([]);
$extendedStructure = array_merge($extendedStructure, $place->structure);

parent::__construct(
$attributes, array_merge($this->structure, $this->extendedStructure, $extendedStructure)
);
}

/**
* Set the opening hours of the business.
*
Expand Down
4 changes: 4 additions & 0 deletions src/ContextTypes/Organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class Organization extends Thing
'logo' => ImageObject::class,
'contactPoint' => ContactPoint::class,
'email' => null,
'telephone' => null,
'review' => Review::class,
'aggregateRating' => AggregateRating::class,
'areaServed' => null,
];

/**
Expand Down
2 changes: 2 additions & 0 deletions src/ContextTypes/Place.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class Place extends Thing
'address' => PostalAddress::class,
'review' => Review::class,
'aggregateRating' => AggregateRating::class,
'geo' => GeoCoordinates::class,
'hasMap' => null,
];

/**
Expand Down