/** * Initialize a Taxonomy Node * * @param string $id * @param string $name * @param array $children * @param string $parent */ public function __construct($id, $name, $children = [], $parent = null) { $this->id = (int) $id; $this->name = $name; $this->children = $children; $this->parent = (int) $parent; $this->slug = Utils::strSlug($name); }
/** * Construct the Class, takes a single xml fragment containing a single destination * * @param string $xml */ public function __construct($xml) { $xml = simplexml_load_string($xml, null, LIBXML_NOCDATA); $json = json_encode($xml); $xml = json_decode($json, TRUE); //flatten the data to make the mapping schema simple $dotnotated_array = Utils::arrayDot($xml); $this->id = $dotnotated_array['@attributes.atlas_id']; $this->title = $dotnotated_array['@attributes.title']; $this->slug = Utils::strSlug($dotnotated_array['@attributes.title-ascii']); $this->map($dotnotated_array); }