Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected parameter of type 'Cycle\Annotated\Locator\EmbeddingLocatorInterface', 'Spiral\Tokenizer\ClassLocator' provided #468

Closed
1 task done
Gokujo opened this issue Mar 13, 2024 · 2 comments
Assignees
Labels
type:question Further information is requested

Comments

@Gokujo
Copy link

Gokujo commented Mar 13, 2024

No duplicates 馃ゲ.

  • I have searched for a similar issue in our bug tracker and didn't find any solutions.

What happened?

I had some free time and got back to my project. And I am following this documentation: https://cycle-orm.dev/docs/annotated-prerequisites/current/en

$classLocator = (new Tokenizer\Tokenizer(new Tokenizer\Config\TokenizerConfig([
    'directories' => ['src/'],
])))->classLocator();

$schema = (new Schema\Compiler())->compile(new Schema\Registry($dbal), [
    new Schema\Generator\ResetTables(),             // re-declared table schemas (remove columns)
    new Annotated\Embeddings($classLocator),        // register embeddable entities
    new Annotated\Entities($classLocator),          // register annotated entities
    new Annotated\TableInheritance(),               // register STI/JTI
    new Annotated\MergeColumns(),                   // register columns from attributes
    new Schema\Generator\GenerateRelations(),       // generate entity relations
    new Schema\Generator\GenerateModifiers(),       // generate changes from schema modifiers
    new Schema\Generator\ValidateEntities(),        // make sure all entity schemas are correct
    new Schema\Generator\RenderTables(),            // declare table schemas
    new Schema\Generator\RenderRelations(),         // declare relation keys and indexes
    new Schema\Generator\RenderModifiers(),         // render all schema modifiers
    new Schema\Generator\ForeignKeys(),             // Define foreign key constraints
    new Annotated\MergeIndexes(),                   // register indexes from attributes
    new Schema\Generator\SyncTables(),              // sync table changes to database
    new Schema\Generator\GenerateTypecast(),        // typecast non string columns
]);

Problem occurs in this linies

    new Annotated\Embeddings($classLocator),        // register embeddable entities
    new Annotated\Entities($classLocator),          // register annotated entities

Problem description: Expected parameter of type 'Cycle\Annotated\Locator\EmbeddingLocatorInterface', 'Spiral\Tokenizer\ClassLocator' provided

Version

ORM 2.7.1
PHP 8.1
@Gokujo Gokujo added status:to be verified Needs to be reproduced and validated. type:bug Bug labels Mar 13, 2024
@msmakouz
Copy link
Member

@Gokujo Hello, we have updated the installation section. In the new version of cycle/annotated, this configuration looks slightly different. Here is the correct example:

use Cycle\Schema;
use Cycle\Annotated;
use Cycle\Annotated\Locator\TokenizerEmbeddingLocator;
use Cycle\Annotated\Locator\TokenizerEntityLocator;

$embeddingLocator = new TokenizerEmbeddingLocator($classLocator);
$entityLocator = new TokenizerEntityLocator($classLocator);

$schema = (new Schema\Compiler())->compile(new Schema\Registry($dbal), [
    new Schema\Generator\ResetTables(),             // Reconfigure table schemas (deletes columns if necessary)
    new Annotated\Embeddings($embeddingLocator),    // Recognize embeddable entities
    new Annotated\Entities($entityLocator),         // Identify attributed entities
    new Annotated\TableInheritance(),               // Setup Single Table or Joined Table Inheritance
    new Annotated\MergeColumns(),                   // Integrate table #[Column] attributes
    new Schema\Generator\GenerateRelations(),       // Define entity relationships
    new Schema\Generator\GenerateModifiers(),       // Apply schema modifications
    new Schema\Generator\ValidateEntities(),        // Ensure entity schemas adhere to conventions
    new Schema\Generator\RenderTables(),            // Create table schemas
    new Schema\Generator\RenderRelations(),         // Establish keys and indexes for relationships
    new Schema\Generator\RenderModifiers(),         // Implement schema modifications
    new Schema\Generator\ForeignKeys(),             // Define foreign key constraints
    new Annotated\MergeIndexes(),                   // Merge table index attributes
    new Schema\Generator\SyncTables(),              // Align table changes with the database
    new Schema\Generator\GenerateTypecast(),        // Typecast non-string columns
]);

@msmakouz msmakouz added type:question Further information is requested and removed type:bug Bug status:to be verified Needs to be reproduced and validated. labels Mar 28, 2024
@Gokujo
Copy link
Author

Gokujo commented Mar 28, 2024

Thx, solved

@Gokujo Gokujo closed this as completed Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Further information is requested
Projects
Archived in project
Development

No branches or pull requests

2 participants