Skip to content

Commit

Permalink
[modules] Added support to stringify entity to track possible errors …
Browse files Browse the repository at this point in the history
…(#121)
  • Loading branch information
actions-user committed May 11, 2023
1 parent d7cab51 commit 2311c75
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Entities/Channels/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use IPub\DoctrineCrud\Mapping\Annotation as IPubDoctrine;
use IPub\DoctrineDynamicDiscriminatorMap\Entities as DoctrineDynamicDiscriminatorMapEntities;
use IPub\DoctrineTimestampable;
use Nette\Utils;
use Ramsey\Uuid;

/**
Expand Down Expand Up @@ -282,4 +283,12 @@ public function getDiscriminatorName(): string
return 'channel';
}

/**
* @throws Utils\JsonException
*/
public function __toString(): string
{
return Utils\Json::encode($this->toArray());
}

}
9 changes: 9 additions & 0 deletions src/Entities/Channels/Controls/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use FastyBird\Module\Devices\Entities;
use IPub\DoctrineCrud\Mapping\Annotation as IPubDoctrine;
use IPub\DoctrineTimestampable;
use Nette\Utils;
use Ramsey\Uuid;

/**
Expand Down Expand Up @@ -107,4 +108,12 @@ public function getSource(): MetadataTypes\ModuleSource
return MetadataTypes\ModuleSource::get(MetadataTypes\ModuleSource::SOURCE_MODULE_DEVICES);
}

/**
* @throws Utils\JsonException
*/
public function __toString(): string
{
return Utils\Json::encode($this->toArray());
}

}
12 changes: 12 additions & 0 deletions src/Entities/Channels/Properties/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use FastyBird\Module\Devices\Entities;
use FastyBird\Module\Devices\Exceptions;
use IPub\DoctrineCrud\Mapping\Annotation as IPubDoctrine;
use Nette\Utils;
use Ramsey\Uuid;
use function array_merge;

Expand Down Expand Up @@ -376,4 +377,15 @@ public function toArray(): array
]);
}

/**
* @throws Exceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws Utils\JsonException
*/
public function __toString(): string
{
return Utils\Json::encode($this->toArray());
}

}
9 changes: 9 additions & 0 deletions src/Entities/Connectors/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use IPub\DoctrineCrud\Mapping\Annotation as IPubDoctrine;
use IPub\DoctrineDynamicDiscriminatorMap\Entities as DoctrineDynamicDiscriminatorMapEntities;
use IPub\DoctrineTimestampable;
use Nette\Utils;
use Ramsey\Uuid;

/**
Expand Down Expand Up @@ -309,4 +310,12 @@ public function getSource(): MetadataTypes\ModuleSource|MetadataTypes\PluginSour
return MetadataTypes\ModuleSource::get(MetadataTypes\ModuleSource::SOURCE_MODULE_DEVICES);
}

/**
* @throws Utils\JsonException
*/
public function __toString(): string
{
return Utils\Json::encode($this->toArray());
}

}
9 changes: 9 additions & 0 deletions src/Entities/Connectors/Controls/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use FastyBird\Module\Devices\Entities;
use IPub\DoctrineCrud\Mapping\Annotation as IPubDoctrine;
use IPub\DoctrineTimestampable;
use Nette\Utils;
use Ramsey\Uuid;

/**
Expand Down Expand Up @@ -107,4 +108,12 @@ public function getSource(): MetadataTypes\ModuleSource
return MetadataTypes\ModuleSource::get(MetadataTypes\ModuleSource::SOURCE_MODULE_DEVICES);
}

/**
* @throws Utils\JsonException
*/
public function __toString(): string
{
return Utils\Json::encode($this->toArray());
}

}
14 changes: 14 additions & 0 deletions src/Entities/Connectors/Properties/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
namespace FastyBird\Module\Devices\Entities\Connectors\Properties;

use Doctrine\ORM\Mapping as ORM;
use FastyBird\Library\Metadata\Exceptions as MetadataExceptions;
use FastyBird\Module\Devices\Entities;
use FastyBird\Module\Devices\Exceptions;
use IPub\DoctrineCrud\Mapping\Annotation as IPubDoctrine;
use Nette\Utils;
use Ramsey\Uuid;
use function array_merge;

Expand Down Expand Up @@ -87,4 +90,15 @@ public function toArray(): array
]);
}

/**
* @throws Exceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws Utils\JsonException
*/
public function __toString(): string
{
return Utils\Json::encode($this->toArray());
}

}
9 changes: 9 additions & 0 deletions src/Entities/Devices/Controls/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use FastyBird\Module\Devices\Entities;
use IPub\DoctrineCrud\Mapping\Annotation as IPubDoctrine;
use IPub\DoctrineTimestampable;
use Nette\Utils;
use Ramsey\Uuid;

/**
Expand Down Expand Up @@ -107,4 +108,12 @@ public function getSource(): MetadataTypes\ModuleSource
return MetadataTypes\ModuleSource::get(MetadataTypes\ModuleSource::SOURCE_MODULE_DEVICES);
}

/**
* @throws Utils\JsonException
*/
public function __toString(): string
{
return Utils\Json::encode($this->toArray());
}

}
9 changes: 9 additions & 0 deletions src/Entities/Devices/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use IPub\DoctrineCrud\Mapping\Annotation as IPubDoctrine;
use IPub\DoctrineDynamicDiscriminatorMap\Entities as DoctrineDynamicDiscriminatorMapEntities;
use IPub\DoctrineTimestampable;
use Nette\Utils;
use Ramsey\Uuid;
use function strval;

Expand Down Expand Up @@ -420,4 +421,12 @@ public function getSource(): MetadataTypes\ModuleSource|MetadataTypes\PluginSour
return MetadataTypes\ModuleSource::get(MetadataTypes\ModuleSource::SOURCE_MODULE_DEVICES);
}

/**
* @throws Utils\JsonException
*/
public function __toString(): string
{
return Utils\Json::encode($this->toArray());
}

}
12 changes: 12 additions & 0 deletions src/Entities/Devices/Properties/Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use FastyBird\Module\Devices\Entities;
use FastyBird\Module\Devices\Exceptions;
use IPub\DoctrineCrud\Mapping\Annotation as IPubDoctrine;
use Nette\Utils;
use Ramsey\Uuid;
use function array_merge;

Expand Down Expand Up @@ -374,4 +375,15 @@ public function toArray(): array
]);
}

/**
* @throws Exceptions\InvalidState
* @throws MetadataExceptions\InvalidArgument
* @throws MetadataExceptions\InvalidState
* @throws Utils\JsonException
*/
public function __toString(): string
{
return Utils\Json::encode($this->toArray());
}

}

0 comments on commit 2311c75

Please sign in to comment.