diff --git a/Model/FamilyInterface.php b/Model/FamilyInterface.php
index 105ac4b..68b1651 100644
--- a/Model/FamilyInterface.php
+++ b/Model/FamilyInterface.php
@@ -26,6 +26,11 @@ interface FamilyInterface
*/
public function getCode();
+ /**
+ * @return string
+ */
+ public function getLabel();
+
/**
* @return string
*/
diff --git a/Profiler/DataLoaderCollector.php b/Profiler/DataLoaderCollector.php
index fa4a132..9582119 100644
--- a/Profiler/DataLoaderCollector.php
+++ b/Profiler/DataLoaderCollector.php
@@ -1,4 +1,12 @@
-
*/
class DataLoaderCollector extends DataCollector
{
@@ -53,6 +63,17 @@ public function collect(Request $request, Response $response, \Exception $except
}
}
+ /**
+ * {@inheritdoc}
+ */
+ public function reset()
+ {
+ $this->data = [
+ 'nodes' => [],
+ 'count' => null,
+ ];
+ }
+
/**
* @return int
*/
diff --git a/Profiler/ModelConfigurationDataCollector.php b/Profiler/ModelConfigurationDataCollector.php
index 0d45e17..4befe20 100644
--- a/Profiler/ModelConfigurationDataCollector.php
+++ b/Profiler/ModelConfigurationDataCollector.php
@@ -10,12 +10,14 @@
namespace Sidus\EAVModelBundle\Profiler;
+use Sidus\EAVModelBundle\Model\AttributeInterface;
+use Sidus\EAVModelBundle\Model\AttributeTypeInterface;
+use Sidus\EAVModelBundle\Model\FamilyInterface;
use Sidus\EAVModelBundle\Registry\AttributeTypeRegistry;
use Sidus\EAVModelBundle\Registry\FamilyRegistry;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
-use Symfony\Component\VarDumper\Cloner\Data;
/**
* Display model configuration in the debug toolbar
@@ -24,16 +26,26 @@
*/
class ModelConfigurationDataCollector extends DataCollector
{
+ /** @var array[] */
+ protected $data = [
+ 'families' => [],
+ 'attributeTypes' => [],
+ ];
+
+ /** @var FamilyRegistry */
+ protected $familyRegistry;
+
+ /** @var AttributeTypeRegistry */
+ protected $attributeTypeRegistry;
+
/**
* @param FamilyRegistry $familyRegistry
* @param AttributeTypeRegistry $attributeTypeRegistry
*/
public function __construct(FamilyRegistry $familyRegistry, AttributeTypeRegistry $attributeTypeRegistry)
{
- $this->data = [
- 'familyRegistry' => $familyRegistry,
- 'attributeTypeRegistry' => $attributeTypeRegistry,
- ];
+ $this->familyRegistry = $familyRegistry;
+ $this->attributeTypeRegistry = $attributeTypeRegistry;
}
/**
@@ -45,6 +57,12 @@ public function __construct(FamilyRegistry $familyRegistry, AttributeTypeRegistr
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
{
+ foreach ($this->familyRegistry->getFamilies() as $family) {
+ $this->data['families'][$family->getCode()] = $this->parseFamily($family);
+ }
+ foreach ($this->attributeTypeRegistry->getTypes() as $attributeType) {
+ $this->data['attributeTypes'][$attributeType->getCode()] = $this->parseAttributeType($attributeType);
+ }
}
/**
@@ -52,22 +70,26 @@ public function collect(Request $request, Response $response, \Exception $except
*/
public function reset()
{
+ $this->data = [
+ 'families' => [],
+ 'attributeTypes' => [],
+ ];
}
/**
- * @return FamilyRegistry
+ * @return array[]
*/
- public function getFamilyRegistry()
+ public function getFamilies()
{
- return $this->data['familyRegistry'];
+ return $this->data['families'];
}
/**
- * @return AttributeTypeRegistry
+ * @return array[]
*/
- public function getAttributeTypeRegistry()
+ public function getAttributeTypes()
{
- return $this->data['attributeTypeRegistry'];
+ return $this->data['attributeTypes'];
}
/**
@@ -81,12 +103,78 @@ public function getName()
}
/**
- * @param array $data
+ * @param FamilyInterface|null $family
*
- * @return Data|array
+ * @return array|null
*/
- public function wrapData(array $data)
+ protected function parseFamily(FamilyInterface $family = null)
{
- return $this->cloneVar($data);
+ if (null === $family) {
+ return null;
+ }
+
+ return [
+ 'code' => $family->getCode(),
+ 'label' => $family->getLabel(),
+ 'instantiable' => $family->isInstantiable(),
+ 'singleton' => $family->isSingleton(),
+ 'parent' => $family->getParent() ? [
+ 'code' => $family->getParent()->getCode(),
+ 'label' => $family->getParent()->getLabel(),
+ ] : null,
+ 'dataClass' => $family->getDataClass(),
+ 'valueClass' => $family->getValueClass(),
+ 'attributeAsIdentifier' => $this->parseAttribute($family->getAttributeAsIdentifier()),
+ 'attributeAsLabel' => $this->parseAttribute($family->getAttributeAsLabel()),
+ 'attributes' => array_map([$this, 'parseAttribute'], $family->getAttributes()),
+ 'data_class' => $family->getDataClass(),
+ ];
+ }
+
+ /**
+ * @param AttributeInterface|null $attribute
+ *
+ * @return array|null
+ */
+ protected function parseAttribute(AttributeInterface $attribute = null)
+ {
+ if (null === $attribute) {
+ return null;
+ }
+
+ return [
+ 'code' => $attribute->getCode(),
+ 'label' => $attribute->getLabel(),
+ 'group' => $attribute->getGroup(),
+ 'type' => $this->parseAttributeType($attribute->getType()),
+ 'required' => $attribute->isRequired(),
+ 'unique' => $attribute->isUnique(),
+ 'multiple' => $attribute->isMultiple(),
+ 'collection' => $attribute->isCollection(),
+ 'contextMask' => $attribute->getContextMask(),
+ 'validationRules' => $this->cloneVar($attribute->getValidationRules()),
+ 'options' => $this->cloneVar($attribute->getOptions()),
+ 'formOptions' => $this->cloneVar($attribute->getFormOptions()),
+ ];
+ }
+
+ /**
+ * @param AttributeTypeInterface|null $attributeType
+ *
+ * @return array|null
+ */
+ protected function parseAttributeType(AttributeTypeInterface $attributeType = null)
+ {
+ if (null === $attributeType) {
+ return null;
+ }
+
+ return [
+ 'code' => $attributeType->getCode(),
+ 'relation' => $attributeType->isRelation(),
+ 'embedded' => $attributeType->isEmbedded(),
+ 'databaseType' => $attributeType->getDatabaseType(),
+ 'formType' => $attributeType->getFormType(),
+ ];
}
}
diff --git a/Resources/views/Profiler/sidus_eav_model.html.twig b/Resources/views/Profiler/sidus_eav_model.html.twig
index b7e0ce7..ccab15c 100644
--- a/Resources/views/Profiler/sidus_eav_model.html.twig
+++ b/Resources/views/Profiler/sidus_eav_model.html.twig
@@ -10,11 +10,11 @@
{% set text %}
Attribute types
- {{ collector.attributeTypeRegistry.types|length }}
+ {{ collector.attributeTypes|length }}
Families
- {{ collector.familyRegistry.familyCodes|length }}
+ {{ collector.families|length }}
{% endset %}
@@ -61,7 +61,7 @@
Families
- {{ collector.familyRegistry.familyCodes|length }}
+ {{ collector.families|length }}
@@ -75,17 +75,17 @@
- {% for family in collector.familyRegistry.families %}
+ {% for family in collector.families %}
{# @var family \Sidus\EAVModelBundle\Model\FamilyInterface #}
{{ family.code }}
- {{ family }}
+ {{ family.label }}
|
{% if family.parent %}
{{ family.parent.code }}
- {{ family.parent }}
+ {{ family.parent.label }}
{% endif %}
|
@@ -147,7 +147,7 @@
|
{{ attribute.code }}
- {{ attribute }}
+ {{ attribute.label }}
|
{{ attribute.group }}
@@ -176,18 +176,16 @@
{{ attribute.contextMask|join(', ') }}
Validation Rules:
- {% for validationRule in attribute.validationRules %}
- {{ profiler_dump(collector.wrapData(validationRule), maxDepth=1) }}
- {% endfor %}
+ {{ profiler_dump(attribute.validationRules, maxDepth=2) }}
|
- Options:
- - {{ profiler_dump(collector.wrapData(attribute.options), maxDepth=1) }}
+ - {{ profiler_dump(attribute.options, maxDepth=1) }}
- Form options:
- - {{ profiler_dump(collector.wrapData(attribute.formOptions), maxDepth=1) }}
+ - {{ profiler_dump(attribute.formOptions, maxDepth=1) }}
|
@@ -206,7 +204,7 @@
Attribute Types
- {{ collector.attributeTypeRegistry.types|length }}
+ {{ collector.attributeTypes|length }}
@@ -219,7 +217,7 @@
- {% for attributeType in collector.attributeTypeRegistry.types %}
+ {% for attributeType in collector.attributeTypes %}
{{ attributeType.code }} |
{{ attributeType.databaseType }} |