Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Call to a member function subject() on a non-object #2

Closed
daguayo opened this issue Oct 30, 2014 · 8 comments
Closed

Call to a member function subject() on a non-object #2

daguayo opened this issue Oct 30, 2014 · 8 comments
Assignees
Labels

Comments

@daguayo
Copy link

daguayo commented Oct 30, 2014

Hi!

I'm trying to make a basic example with UserTools. I deployed a fresh CakePHP 3.0.

php composer.phar create-project --prefer-dist -s dev cakephp/app app

Then I installed UserTools as described in Installation.md:

php ../composer.phar require burzum/cakephp-user-tools:dev-develop

I used Migrations plugin to create the table:

bin/cake Migrations.migrations migrate -p UserTools

To make it work, I had to change two lines in /config/Migrations/20140902003044_initial.php:

  • Commented line 22 ->addColumn('id', 'char'..., because Migrations complained like [PDOException] SQLSTATE[42S21]: Column already exists: 1060: Duplicate column name 'id'
  • deleted 'unique' => true in line 23, because Migrations complained like [RuntimeException] 'unique' is not a valid column option.

Then I created the following controller:

<?php

namespace App\Controller;

class UsersController extends AppController {
    public $components = array(
        'Burzum/UserTools.UserTool'
    );
} 

Note that Installation.md does not suggest the "Burzum/" part.

Anyway, when I test the controller, I get 2 warnings and 1 error:

Strict (2048): Declaration of Burzum\UserTools\Controller\Component\UserToolComponent::initialize() should be compatible with Cake\Controller\Component::initialize(array $config) [ROOT/plugins/Burzum/UserTools/src/Controller/Component/UserToolComponent.php, line 604]

Warning (4096): Argument 1 passed to Burzum\UserTools\Controller\Component\UserToolComponent::initialize() must be an instance of Cake\Event\Event, array given, called in /path/to/cakephp-app/vendor/cakephp/cakephp/src/Controller/Component.php on line 108 and defined [ROOT/plugins/Burzum/UserTools/src/Controller/Component/UserToolComponent.php, line 228]

Error: Call to a member function subject() on a non-object  
File  /path/to/cakephp-app/plugins/Burzum/UserTools/src/Controller/Component/UserToolComponent.php  
Line: 229

Any idea about what is failing or what I'm doing wrong?

$ php -v
PHP 5.5.18 (cli) (built: Oct 28 2014 22:41:49)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

Thank you!

@burzum
Copy link
Owner

burzum commented Oct 30, 2014

Pull, I've fixed the migration, need more time to check the component. Probably something because of the recent change of the plugin to my namespace.

@burzum
Copy link
Owner

burzum commented Oct 30, 2014

The component fails because of a change in the core, I'll need to fix that.

@burzum
Copy link
Owner

burzum commented Oct 30, 2014

OK, it should be fixed, please try again and let me know.

Thanks for that detailed issue report by the way! 👍 I wish all people would do it this way.

@burzum burzum added the bug label Oct 30, 2014
@burzum
Copy link
Owner

burzum commented Oct 30, 2014

Plugin views can't be loaded any-more as well as they were before... So copy the templates around or wait until I figured out what has changed and. Migration should work now and the component as well except that it can't load the views.

@burzum
Copy link
Owner

burzum commented Oct 30, 2014

I fixed it in the CakePHP core cakephp/cakephp#5019, the plugin is OK now, I've tested it but you'll have to wait until somebody accepts my PR or fixes it otherwise.

@burzum burzum self-assigned this Oct 30, 2014
@daguayo
Copy link
Author

daguayo commented Oct 30, 2014

I tried Migration and it works great. Thanks! I'm going to play with the views now.

@burzum burzum closed this as completed Oct 30, 2014
@burzum
Copy link
Owner

burzum commented Oct 30, 2014

You'll have to patch the core (until its fixed) or copy the views and configure the component to use them from their new location. See the huge component defaultConfig array in the class, it should be pretty self-explaining.

@burzum
Copy link
Owner

burzum commented Nov 1, 2014

@daguayo I've made more fixes to the Component and Behavior. Please keep reporting issues, Cake3 is still in development (there are ongoing API changes) and the plugin as well. However, I would appreciate it if you use it and provide some feedback, thank you! 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants