I'm following: Shopware 6 - Developer Training Basic (EN) From:
Service "Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition" is tagged as "shopware.entity.definition" and must therefore be of type "Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition".
Complete log:
www-data@8d1dae6bf0a3:~/html$ bin/console plugin:install --activate SwagShopFinder
Shopware\Core\Framework\DependencyInjection\DependencyInjectionException^ {#10579
#message: "Service "Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition" is tagged as "shopware.entity.definition" and must therefore be of type "Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition"."
#code: 0
#file: "./vendor/shopware/core/Framework/DependencyInjection/DependencyInjectionException.php"
#line: 37
-statusCode: 500
-headers: []
#parameters: []
#statusCode: 500
#errorCode: "FRAMEWORK__TAGGED_SERVICE_HAS_WRONG_TYPE"
trace: {
./vendor/shopware/core/Framework/DependencyInjection/DependencyInjectionException.php:37 { …}
./vendor/shopware/core/Framework/DependencyInjection/CompilerPass/EntityCompilerPass.php:52 { …}
./vendor/shopware/core/Framework/DependencyInjection/CompilerPass/EntityCompilerPass.php:26 { …}
./vendor/symfony/dependency-injection/Compiler/Compiler.php:73 { …}
./vendor/symfony/dependency-injection/ContainerBuilder.php:814 { …}
./vendor/symfony/http-kernel/Kernel.php:498 { …}
./vendor/symfony/http-kernel/Kernel.php:743 { …}
./vendor/symfony/http-kernel/Kernel.php:120 { …}
./vendor/shopware/core/Kernel.php:190 { …}
./bin/console:54 {
{closure}^
› $application = new Application($kernel);
› $kernel->boot();
›
}
./vendor/symfony/runtime/Resolver/DebugClosureResolver.php:25 { …}
./vendor/autoload_runtime.php:24 { …}
./bin/console:17 { …}
}
}
www-data@8d1dae6bf0a3:~/html$
Resources/config/services.xml
<container xmlns=";
xmlns:xsi=";
xsi:schemaLocation=" .0.xsd">
<services>
<service id="SwagShopFinder\Command\ExampleCommand">
<tag name="consolemand"/>
</service>
<service id="SwagShopFinder\ScheduledTask\ExampleTask">
<tag name="shopware.scheduled.task"/>
</service>
<service id="SwagShopFinder\Subscriber\MySubscriber">
<tag name="kernel.event_subscriber"/>
</service>
<service id="SwagShopFinder\Storefront\Controller\ExampleController" public="true">
<call method="setContainer">
<argument type="service" id="service_container"/>
</call>
</service>
<service id="SwagShopFinder\Core\Content\Example\SalesChannel\ExampleRoute">
<argument type="service" id="product.repository"/>
</service>
<service id="SwagShopFinder\Service\CustomFieldsInstaller">
<argument type="service" id="custom_field_set.repository"/>
<argument type="service" id="custom_field_set_relation.repository"/>
</service>
<service id="Swag\ShopFinder\Core\Content\ShopFinder\ShopFinderDefinition" >
<tag name="shopware.entity.definition" entity="swag_shop_finder" />
</service>
</services>
</container>
ShopFinderCollection
<?php
namespace Swag\ShopFinder\Core\Content\ShopFinder;
use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection;
class ShopFinderCollection extends EntityCollection
{
protected function getExpectedClass(): string
{
return ShopFinderEntity::class;
}
}
ShopFinderDefinition
<?php declare(strict_types=1);
namespace Swag\ShopFinder\Core\Content\ShopFinder;
use Shopware\Core\Framework\App\Manifest\Xml\CustomField\CustomFieldTypes\BoolField;
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required;
use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\ManyToOneAssociationField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\StringField;
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection;
use Shopware\Core\System\Country\CountryDefinition;
use Shopware\Core\System\CustomEntity\CustomEntityCollection;
class ShopFinderDefinition extends EntityDefinition
{
public function getEntityName(): string
{
return "swag_shop_finder";
}
public function getEntityClass(): string
{
return ShopFinderEntity::class;
}
public function getCollectionClass(): string
{
return ShopFinderCollection::class;
}
protected function defineFields(): FieldCollection
{
/*
IdField id
BoolField active
StringField name
StringField street
StringField post_code
StringField city
StringField url
StringField telephone
StringField open_times
FkField country_id
ManyToOneAssociation country to CountryDefinition
required: name street post_code city
*/
return new FieldCollection([
(new IdField("id", "id"))->addFlags(new Required(), new PrimaryKey()),
new BoolField("active", "active"),
(new StringField("name", "name"))->addFlags(new Required()),
(new StringField("street", "street"))->addFlags(new Required()),
(new StringField("post_code", "postCode"))->addFlags(new Required()),
(new StringField("city", "city"))->addFlags(new Required()),
new StringField("url", "url"),
new StringField("telephone", "telephone"),
new StringField("open_times", "openTimes"),
new FkField("country_id", "countryId", CountryDefinition::class),
new ManyToOneAssociationField(
"country",
"country_id",
CountryDefinition::class,
"id",
false
)
]);
}
}
ShopFinderEntity
namespace Swag\ShopFinder\Core\Content\ShopFinder;
use Shopware\Core\Framework\DataAbstractionLayer\Entity;
use Shopware\Core\Framework\DataAbstractionLayer\EntityIdTrait;
class ShopFinderEntity extends Entity
{
use EntityIdTrait;
protected $active;
protected $name;
public function isName(): bool
{
return $this->name;
}
public function setName(bool $name): void
{
$this->name = $name;
}
protected $street;
public function isStreet(): bool
{
return $this->street;
}
public function setStreet(bool $street): void
{
$this->street = $street;
}
protected $postCode;
public function isPostCode(): bool
{
return $this->postCode;
}
public function setPostCode(bool $postCode): void
{
$this->postCode = $postCode;
}
protected $city;
public function isCity(): bool
{
return $this->city;
}
public function setCity(bool $city): void
{
$this->city = $city;
}
protected $url;
public function isUrl(): bool
{
return $this->url;
}
public function setUrl(bool $url): void
{
$this->url = $url;
}
protected $telephone;
public function isTelephone(): bool
{
return $this->telephone;
}
public function setTelephone(bool $telephone): void
{
$this->telephone = $telephone;
}
protected $openTimes;
public function isOpenTimes(): bool
{
return $this->openTimes;
}
public function setOpenTimes(bool $openTimes): void
{
$this->openTimes = $openTimes;
}
protected $country;
public function isCountry(): bool
{
return $this->country;
}
public function setCountry(bool $country): void
{
$this->country = $country;
}
public function isActive(): bool
{
return $this->active;
}
public function setActive(bool $active): void
{
$this->active = $active;
}
}
?>
I'm following: Shopware 6 - Developer Training Basic (EN) From: https://academy.shopware/courses/take/shopware-6-developer-training-english/lessons/9225171-entities
Service "Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition" is tagged as "shopware.entity.definition" and must therefore be of type "Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition".
Complete log:
www-data@8d1dae6bf0a3:~/html$ bin/console plugin:install --activate SwagShopFinder
Shopware\Core\Framework\DependencyInjection\DependencyInjectionException^ {#10579
#message: "Service "Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition" is tagged as "shopware.entity.definition" and must therefore be of type "Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition"."
#code: 0
#file: "./vendor/shopware/core/Framework/DependencyInjection/DependencyInjectionException.php"
#line: 37
-statusCode: 500
-headers: []
#parameters: []
#statusCode: 500
#errorCode: "FRAMEWORK__TAGGED_SERVICE_HAS_WRONG_TYPE"
trace: {
./vendor/shopware/core/Framework/DependencyInjection/DependencyInjectionException.php:37 { …}
./vendor/shopware/core/Framework/DependencyInjection/CompilerPass/EntityCompilerPass.php:52 { …}
./vendor/shopware/core/Framework/DependencyInjection/CompilerPass/EntityCompilerPass.php:26 { …}
./vendor/symfony/dependency-injection/Compiler/Compiler.php:73 { …}
./vendor/symfony/dependency-injection/ContainerBuilder.php:814 { …}
./vendor/symfony/http-kernel/Kernel.php:498 { …}
./vendor/symfony/http-kernel/Kernel.php:743 { …}
./vendor/symfony/http-kernel/Kernel.php:120 { …}
./vendor/shopware/core/Kernel.php:190 { …}
./bin/console:54 {
{closure}^
› $application = new Application($kernel);
› $kernel->boot();
›
}
./vendor/symfony/runtime/Resolver/DebugClosureResolver.php:25 { …}
./vendor/autoload_runtime.php:24 { …}
./bin/console:17 { …}
}
}
www-data@8d1dae6bf0a3:~/html$
Resources/config/services.xml
<container xmlns="http://symfony/schema/dic/services"
xmlns:xsi="http://www.w3./2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony/schema/dic/services http://symfony/schema/dic/services/services-1.0.xsd">
<services>
<service id="SwagShopFinder\Command\ExampleCommand">
<tag name="consolemand"/>
</service>
<service id="SwagShopFinder\ScheduledTask\ExampleTask">
<tag name="shopware.scheduled.task"/>
</service>
<service id="SwagShopFinder\Subscriber\MySubscriber">
<tag name="kernel.event_subscriber"/>
</service>
<service id="SwagShopFinder\Storefront\Controller\ExampleController" public="true">
<call method="setContainer">
<argument type="service" id="service_container"/>
</call>
</service>
<service id="SwagShopFinder\Core\Content\Example\SalesChannel\ExampleRoute">
<argument type="service" id="product.repository"/>
</service>
<service id="SwagShopFinder\Service\CustomFieldsInstaller">
<argument type="service" id="custom_field_set.repository"/>
<argument type="service" id="custom_field_set_relation.repository"/>
</service>
<service id="Swag\ShopFinder\Core\Content\ShopFinder\ShopFinderDefinition" >
<tag name="shopware.entity.definition" entity="swag_shop_finder" />
</service>
</services>
</container>
ShopFinderCollection
<?php
namespace Swag\ShopFinder\Core\Content\ShopFinder;
use Shopware\Core\Framework\DataAbstractionLayer\EntityCollection;
class ShopFinderCollection extends EntityCollection
{
protected function getExpectedClass(): string
{
return ShopFinderEntity::class;
}
}
ShopFinderDefinition
<?php declare(strict_types=1);
namespace Swag\ShopFinder\Core\Content\ShopFinder;
use Shopware\Core\Framework\App\Manifest\Xml\CustomField\CustomFieldTypes\BoolField;
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\Field\FkField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required;
use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\ManyToOneAssociationField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\StringField;
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection;
use Shopware\Core\System\Country\CountryDefinition;
use Shopware\Core\System\CustomEntity\CustomEntityCollection;
class ShopFinderDefinition extends EntityDefinition
{
public function getEntityName(): string
{
return "swag_shop_finder";
}
public function getEntityClass(): string
{
return ShopFinderEntity::class;
}
public function getCollectionClass(): string
{
return ShopFinderCollection::class;
}
protected function defineFields(): FieldCollection
{
/*
IdField id
BoolField active
StringField name
StringField street
StringField post_code
StringField city
StringField url
StringField telephone
StringField open_times
FkField country_id
ManyToOneAssociation country to CountryDefinition
required: name street post_code city
*/
return new FieldCollection([
(new IdField("id", "id"))->addFlags(new Required(), new PrimaryKey()),
new BoolField("active", "active"),
(new StringField("name", "name"))->addFlags(new Required()),
(new StringField("street", "street"))->addFlags(new Required()),
(new StringField("post_code", "postCode"))->addFlags(new Required()),
(new StringField("city", "city"))->addFlags(new Required()),
new StringField("url", "url"),
new StringField("telephone", "telephone"),
new StringField("open_times", "openTimes"),
new FkField("country_id", "countryId", CountryDefinition::class),
new ManyToOneAssociationField(
"country",
"country_id",
CountryDefinition::class,
"id",
false
)
]);
}
}
ShopFinderEntity
namespace Swag\ShopFinder\Core\Content\ShopFinder;
use Shopware\Core\Framework\DataAbstractionLayer\Entity;
use Shopware\Core\Framework\DataAbstractionLayer\EntityIdTrait;
class ShopFinderEntity extends Entity
{
use EntityIdTrait;
protected $active;
protected $name;
public function isName(): bool
{
return $this->name;
}
public function setName(bool $name): void
{
$this->name = $name;
}
protected $street;
public function isStreet(): bool
{
return $this->street;
}
public function setStreet(bool $street): void
{
$this->street = $street;
}
protected $postCode;
public function isPostCode(): bool
{
return $this->postCode;
}
public function setPostCode(bool $postCode): void
{
$this->postCode = $postCode;
}
protected $city;
public function isCity(): bool
{
return $this->city;
}
public function setCity(bool $city): void
{
$this->city = $city;
}
protected $url;
public function isUrl(): bool
{
return $this->url;
}
public function setUrl(bool $url): void
{
$this->url = $url;
}
protected $telephone;
public function isTelephone(): bool
{
return $this->telephone;
}
public function setTelephone(bool $telephone): void
{
$this->telephone = $telephone;
}
protected $openTimes;
public function isOpenTimes(): bool
{
return $this->openTimes;
}
public function setOpenTimes(bool $openTimes): void
{
$this->openTimes = $openTimes;
}
protected $country;
public function isCountry(): bool
{
return $this->country;
}
public function setCountry(bool $country): void
{
$this->country = $country;
}
public function isActive(): bool
{
return $this->active;
}
public function setActive(bool $active): void
{
$this->active = $active;
}
}
?>
Share
Improve this question
asked Mar 13 at 10:43
Gjergj KadriuGjergj Kadriu
6085 silver badges10 bronze badges
1 Answer
Reset to default 1Fixed by
namespace SwagShopFinder\Core\Content\ShopFinder;
changing namespace to not add the file name and match the plugin name directories including all path excluding filename.php
so I had:
namespace SwagShopFinder\Core\Content\ShopFinder\ShopFinderCollection
and similar namespaces which were incorrect.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744706980a4589111.html
评论列表(0条)