Overriding an existing controller

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Overriding an existing controller

Marco Ferreri
Hello,

I am trying to override an existing controller of VuFindConsole module. I have been reading the documentation for this page https://vufind.org/wiki/development:plugins:controllers
but I can not override it correctly.

I have created two new local modules. In httpd-vufind.conf I have this:

SetEnv VUFIND_LOCAL_MODULES Test, TestConsole

I also have these folders:

/usr/local/vufind/module/Test/src/Test/
/usr/local/vufind/module/Test/config/
/usr/local/vufind/module/TestConsole/src/TestConsole/
/usr/local/vufind/module/TestConsole/config/

I have created the class /usr/local/vufind/module/TestConsole/src/TestConsole/Controller/ImportController.php 


And I modified as this:

class ImportController extends VuFindConsole\Controller\AbstractBase

And just to test I added a comment to the importXsl action

    public function importXslAction()
    {
    echo "NEW MODULE";


In the original file (/usr/local/vufind/module/VuFindConsole/src/VuFindConsole/Controller/ImportController.php) I put this comment:

    public function importXslAction()
    {
     echo "ORIGINAL MODULE";


I also updated the module.config.php file for TestConsole and added these lines:

<?php
namespace TestConsole\Module\Config;
$config = [
    'controllers' => [
        'invokables' => [
            'import' => 'TestConsole\Controller\ImportController',
        ],
    ],

];

return $config;

After doing this I deleted the cache directories for config and objects.

To test it I run:

[root@Vdevtest vufind]# /usr/local/vufind/harvest/batch-import-xsl.sh ./Metadata/ ../import/metadata.properties
Processing /usr/local/vufind/local/harvest/./Metadata//1499254912_metadata_10771_8371.xml ...
ORIGINAL MODULE

Is there somehing that I miss? 

I would like to be able to use the entire functionality of VuFind and VufindConsole modules but taking into account the new code from Test and TestConsole modules.

Thanks a lot for your help.

Regards,

Marco.




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Overriding an existing controller

Demian Katz

Marco,

 

Environment variables need to be set up in two places – the SetEnv in httpd-vufind.conf only applies in the context where VuFind is executing through Apache (i.e. when you access it over the web). If you are running from the command line, Apache is not involved, so you need the variable set in your local shell environment. Just run this before doing anything else:

 

export VUFIND_LOCAL_MODULES=Test,TestConsole

 

You can also add this line to /etc/profile.d/vufind.sh if you want it to be set up by default whenever you start a new shell session.

 

I suspect that this is the missing piece of the puzzle for you – but please let me know if you are still having problems.

 

- Demian

 

From: Marco Ferreri [mailto:[hidden email]]
Sent: Thursday, July 06, 2017 7:44 AM
To: [hidden email]
Subject: [VuFind-Tech] Overriding an existing controller

 

Hello,

 

I am trying to override an existing controller of VuFindConsole module. I have been reading the documentation for this page https://vufind.org/wiki/development:plugins:controllers

but I can not override it correctly.

 

I have created two new local modules. In httpd-vufind.conf I have this:

 

SetEnv VUFIND_LOCAL_MODULES Test, TestConsole

 

I also have these folders:

 

/usr/local/vufind/module/Test/src/Test/

/usr/local/vufind/module/Test/config/

/usr/local/vufind/module/TestConsole/src/TestConsole/

/usr/local/vufind/module/TestConsole/config/

 

I have created the class /usr/local/vufind/module/TestConsole/src/TestConsole/Controller/ImportController.php 

 

 

And I modified as this:

 

class ImportController extends VuFindConsole\Controller\AbstractBase

 

And just to test I added a comment to the importXsl action

 

    public function importXslAction()

    {

            echo "NEW MODULE";

 

 

In the original file (/usr/local/vufind/module/VuFindConsole/src/VuFindConsole/Controller/ImportController.php) I put this comment:

 

    public function importXslAction()

    {

            echo "ORIGINAL MODULE";

 

 

I also updated the module.config.php file for TestConsole and added these lines:

 

<?php

namespace TestConsole\Module\Config;

$config = [

    'controllers' => [

        'invokables' => [

            'import' => 'TestConsole\Controller\ImportController',

        ],

    ],

 

];

 

return $config;

 

After doing this I deleted the cache directories for config and objects.

 

To test it I run:

 

[root@Vdevtest vufind]# /usr/local/vufind/harvest/batch-import-xsl.sh ./Metadata/ ../import/metadata.properties

Processing /usr/local/vufind/local/harvest/./Metadata//1499254912_metadata_10771_8371.xml ...

ORIGINAL MODULE

 

Is there somehing that I miss? 

 

I would like to be able to use the entire functionality of VuFind and VufindConsole modules but taking into account the new code from Test and TestConsole modules.

 

Thanks a lot for your help.

 

Regards,

 

Marco.

 

 

 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Fwd: Overriding an existing controller

Marco Ferreri
Hello Demian,

Thanks for your quick answer but it did not fix my problem.

Before I run it I executed set | grep VUF

And this is what I have:

VUFIND_HOME=/usr/local/vufind
VUFIND_LOCAL_DIR=/usr/local/vufind/local
VUFIND_LOCAL_MODULES=TestConsole,Test

But the result for the import process was the same.

Any other ideas?

Thanks again.




2017-07-06 14:04 GMT+02:00 Demian Katz <[hidden email]>:

Marco,

 

Environment variables need to be set up in two places – the SetEnv in httpd-vufind.conf only applies in the context where VuFind is executing through Apache (i.e. when you access it over the web). If you are running from the command line, Apache is not involved, so you need the variable set in your local shell environment. Just run this before doing anything else:

 

export VUFIND_LOCAL_MODULES=Test,TestConsole

 

You can also add this line to /etc/profile.d/vufind.sh if you want it to be set up by default whenever you start a new shell session.

 

I suspect that this is the missing piece of the puzzle for you – but please let me know if you are still having problems.

 

- Demian

 

From: Marco Ferreri [mailto:[hidden email]]
Sent: Thursday, July 06, 2017 7:44 AM
To: [hidden email]
Subject: [VuFind-Tech] Overriding an existing controller

 

Hello,

 

I am trying to override an existing controller of VuFindConsole module. I have been reading the documentation for this page https://vufind.org/wiki/development:plugins:controllers

but I can not override it correctly.

 

I have created two new local modules. In httpd-vufind.conf I have this:

 

SetEnv VUFIND_LOCAL_MODULES Test, TestConsole

 

I also have these folders:

 

/usr/local/vufind/module/Test/src/Test/

/usr/local/vufind/module/Test/config/

/usr/local/vufind/module/TestConsole/src/TestConsole/

/usr/local/vufind/module/TestConsole/config/

 

I have created the class /usr/local/vufind/module/TestConsole/src/TestConsole/Controller/ImportController.php 

 

 

And I modified as this:

 

class ImportController extends VuFindConsole\Controller\AbstractBase

 

And just to test I added a comment to the importXsl action

 

    public function importXslAction()

    {

            echo "NEW MODULE";

 

 

In the original file (/usr/local/vufind/module/VuFindConsole/src/VuFindConsole/Controller/ImportController.php) I put this comment:

 

    public function importXslAction()

    {

            echo "ORIGINAL MODULE";

 

 

I also updated the module.config.php file for TestConsole and added these lines:

 

<?php

namespace TestConsole\Module\Config;

$config = [

    'controllers' => [

        'invokables' => [

            'import' => 'TestConsole\Controller\ImportController',

        ],

    ],

 

];

 

return $config;

 

After doing this I deleted the cache directories for config and objects.

 

To test it I run:

 

[root@Vdevtest vufind]# /usr/local/vufind/harvest/batch-import-xsl.sh ./Metadata/ ../import/metadata.properties

Processing /usr/local/vufind/local/harvest/./Metadata//1499254912_metadata_10771_8371.xml ...

ORIGINAL MODULE

 

Is there somehing that I miss? 

 

I would like to be able to use the entire functionality of VuFind and VufindConsole modules but taking into account the new code from Test and TestConsole modules.

 

Thanks a lot for your help.

 

Regards,

 

Marco.

 

 

 




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Overriding an existing controller

Demian Katz
In reply to this post by Marco Ferreri

Marco,

 

How did you create your local modules? Did you set them up using the install.php script, or did you build them manually? If you built them manually, did you copy the VuFindLocalTemplate (https://github.com/vufind-org/vufind/tree/master/module/VuFindLocalTemplate) and change the namespace in its Module.php file?

 

I would suggest that the next step to debugging is to figure out whether any of your modules are loading at all – you can test this by putting debug output in each module’s module.config.php and/or Module.php.

 

I hope this will help put you back on track, but if you’re still stuck, please share your results and I’ll offer further suggestions!

 

- Demian

 

From: Marco Ferreri [mailto:[hidden email]]
Sent: Thursday, July 06, 2017 8:56 AM
To: [hidden email]
Subject: [VuFind-Tech] Fwd: Overriding an existing controller

 

Hello Demian,

 

Thanks for your quick answer but it did not fix my problem.

 

Before I run it I executed set | grep VUF

 

And this is what I have:

 

VUFIND_HOME=/usr/local/vufind

VUFIND_LOCAL_DIR=/usr/local/vufind/local

VUFIND_LOCAL_MODULES=TestConsole,Test

 

But the result for the import process was the same.

 

Any other ideas?

 

Thanks again.

 

 

 

 

2017-07-06 14:04 GMT+02:00 Demian Katz <[hidden email]>:

Marco,

 

Environment variables need to be set up in two places – the SetEnv in httpd-vufind.conf only applies in the context where VuFind is executing through Apache (i.e. when you access it over the web). If you are running from the command line, Apache is not involved, so you need the variable set in your local shell environment. Just run this before doing anything else:

 

export VUFIND_LOCAL_MODULES=Test,TestConsole

 

You can also add this line to /etc/profile.d/vufind.sh if you want it to be set up by default whenever you start a new shell session.

 

I suspect that this is the missing piece of the puzzle for you – but please let me know if you are still having problems.

 

- Demian

 

From: Marco Ferreri [mailto:[hidden email]]
Sent: Thursday, July 06, 2017 7:44 AM
To: [hidden email]
Subject: [VuFind-Tech] Overriding an existing controller

 

Hello,

 

I am trying to override an existing controller of VuFindConsole module. I have been reading the documentation for this page https://vufind.org/wiki/development:plugins:controllers

but I can not override it correctly.

 

I have created two new local modules. In httpd-vufind.conf I have this:

 

SetEnv VUFIND_LOCAL_MODULES Test, TestConsole

 

I also have these folders:

 

/usr/local/vufind/module/Test/src/Test/

/usr/local/vufind/module/Test/config/

/usr/local/vufind/module/TestConsole/src/TestConsole/

/usr/local/vufind/module/TestConsole/config/

 

I have created the class /usr/local/vufind/module/TestConsole/src/TestConsole/Controller/ImportController.php 

 

 

And I modified as this:

 

class ImportController extends VuFindConsole\Controller\AbstractBase

 

And just to test I added a comment to the importXsl action

 

    public function importXslAction()

    {

            echo "NEW MODULE";

 

 

In the original file (/usr/local/vufind/module/VuFindConsole/src/VuFindConsole/Controller/ImportController.php) I put this comment:

 

    public function importXslAction()

    {

            echo "ORIGINAL MODULE";

 

 

I also updated the module.config.php file for TestConsole and added these lines:

 

<?php

namespace TestConsole\Module\Config;

$config = [

    'controllers' => [

        'invokables' => [

            'import' => 'TestConsole\Controller\ImportController',

        ],

    ],

 

];

 

return $config;

 

After doing this I deleted the cache directories for config and objects.

 

To test it I run:

 

[root@Vdevtest vufind]# /usr/local/vufind/harvest/batch-import-xsl.sh ./Metadata/ ../import/metadata.properties

Processing /usr/local/vufind/local/harvest/./Metadata//1499254912_metadata_10771_8371.xml ...

ORIGINAL MODULE

 

Is there somehing that I miss? 

 

I would like to be able to use the entire functionality of VuFind and VufindConsole modules but taking into account the new code from Test and TestConsole modules.

 

Thanks a lot for your help.

 

Regards,

 

Marco.

 

 

 

 

 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Overriding an existing controller

Marco Ferreri
Hello Demian,

I am sorry but I have still with the problem.

I copied the files from VuFindLocalTemplate and  I changed the names later.

I am not an expert in Zend Framework and I do not know how to set this debug mode in the modules but I tried debugging the application.config.php file putting a print_r($modules) before the return line so anytime I execute the import command I see this:

Array
(
    [0] => ZfcRbac
    [1] => VuFindTheme
    [2] => VuFindSearch
    [3] => VuFind
    [4] => VuFindAdmin
    [5] => VuFindConsole
    [6] => Test
    [7] => TestConsole
)


So I believe I am using this module correctly but it is pointing to the VuFind Controller when I do the import.

Do you have any other idea to fix this?

Thanks a lot.




2017-07-06 15:00 GMT+02:00 Demian Katz <[hidden email]>:

Marco,

 

How did you create your local modules? Did you set them up using the install.php script, or did you build them manually? If you built them manually, did you copy the VuFindLocalTemplate (https://github.com/vufind-org/vufind/tree/master/module/VuFindLocalTemplate) and change the namespace in its Module.php file?

 

I would suggest that the next step to debugging is to figure out whether any of your modules are loading at all – you can test this by putting debug output in each module’s module.config.php and/or Module.php.

 

I hope this will help put you back on track, but if you’re still stuck, please share your results and I’ll offer further suggestions!

 

- Demian

 

From: Marco Ferreri [mailto:[hidden email]]
Sent: Thursday, July 06, 2017 8:56 AM
To: [hidden email]
Subject: [VuFind-Tech] Fwd: Overriding an existing controller

 

Hello Demian,

 

Thanks for your quick answer but it did not fix my problem.

 

Before I run it I executed set | grep VUF

 

And this is what I have:

 

VUFIND_HOME=/usr/local/vufind

VUFIND_LOCAL_DIR=/usr/local/vufind/local

VUFIND_LOCAL_MODULES=TestConsole,Test

 

But the result for the import process was the same.

 

Any other ideas?

 

Thanks again.

 

 

 

 

2017-07-06 14:04 GMT+02:00 Demian Katz <[hidden email]>:

Marco,

 

Environment variables need to be set up in two places – the SetEnv in httpd-vufind.conf only applies in the context where VuFind is executing through Apache (i.e. when you access it over the web). If you are running from the command line, Apache is not involved, so you need the variable set in your local shell environment. Just run this before doing anything else:

 

export VUFIND_LOCAL_MODULES=Test,TestConsole

 

You can also add this line to /etc/profile.d/vufind.sh if you want it to be set up by default whenever you start a new shell session.

 

I suspect that this is the missing piece of the puzzle for you – but please let me know if you are still having problems.

 

- Demian

 

From: Marco Ferreri [mailto:[hidden email]]
Sent: Thursday, July 06, 2017 7:44 AM
To: [hidden email]
Subject: [VuFind-Tech] Overriding an existing controller

 

Hello,

 

I am trying to override an existing controller of VuFindConsole module. I have been reading the documentation for this page https://vufind.org/wiki/development:plugins:controllers

but I can not override it correctly.

 

I have created two new local modules. In httpd-vufind.conf I have this:

 

SetEnv VUFIND_LOCAL_MODULES Test, TestConsole

 

I also have these folders:

 

/usr/local/vufind/module/Test/src/Test/

/usr/local/vufind/module/Test/config/

/usr/local/vufind/module/TestConsole/src/TestConsole/

/usr/local/vufind/module/TestConsole/config/

 

I have created the class /usr/local/vufind/module/TestConsole/src/TestConsole/Controller/ImportController.php 

 

 

And I modified as this:

 

class ImportController extends VuFindConsole\Controller\AbstractBase

 

And just to test I added a comment to the importXsl action

 

    public function importXslAction()

    {

            echo "NEW MODULE";

 

 

In the original file (/usr/local/vufind/module/VuFindConsole/src/VuFindConsole/Controller/ImportController.php) I put this comment:

 

    public function importXslAction()

    {

            echo "ORIGINAL MODULE";

 

 

I also updated the module.config.php file for TestConsole and added these lines:

 

<?php

namespace TestConsole\Module\Config;

$config = [

    'controllers' => [

        'invokables' => [

            'import' => 'TestConsole\Controller\ImportController',

        ],

    ],

 

];

 

return $config;

 

After doing this I deleted the cache directories for config and objects.

 

To test it I run:

 

[root@Vdevtest vufind]# /usr/local/vufind/harvest/batch-import-xsl.sh ./Metadata/ ../import/metadata.properties

Processing /usr/local/vufind/local/harvest/./Metadata//1499254912_metadata_10771_8371.xml ...

ORIGINAL MODULE

 

Is there somehing that I miss? 

 

I would like to be able to use the entire functionality of VuFind and VufindConsole modules but taking into account the new code from Test and TestConsole modules.

 

Thanks a lot for your help.

 

Regards,

 

Marco.

 

 

 

 

 



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Overriding an existing controller

Ere Maijala
One thing I've stumbled on a couple of times: unless you also set
VUFIND_ENV to development in the terminal, the module configs etc. are
cached in local/cache/cli (if my memory serves), and you have to
manually delete the files under local/cache/cli. Not sure if you're
affected, but something to be aware of!

--Ere

Marco Ferreri kirjoitti 7.7.2017 klo 13.08:

> Hello Demian,
>
> I am sorry but I have still with the problem.
>
> I copied the files from VuFindLocalTemplate and  I changed the names later.
>
> I am not an expert in Zend Framework and I do not know how to set this
> debug mode in the modules but I tried debugging the
> application.config.php file putting a print_r($modules) before the
> return line so anytime I execute the import command I see this:
>
> Array
> (
>      [0] => ZfcRbac
>      [1] => VuFindTheme
>      [2] => VuFindSearch
>      [3] => VuFind
>      [4] => VuFindAdmin
>      [5] => VuFindConsole
>      [6] => Test
>      [7] => TestConsole
> )
>
>
> So I believe I am using this module correctly but it is pointing to the
> VuFind Controller when I do the import.
>
> Do you have any other idea to fix this?
>
> Thanks a lot.
>
>
>
>
> 2017-07-06 15:00 GMT+02:00 Demian Katz <[hidden email]
> <mailto:[hidden email]>>:
>
>     Marco,____
>
>     __ __
>
>     How did you create your local modules? Did you set them up using the
>     install.php script, or did you build them manually? If you built
>     them manually, did you copy the VuFindLocalTemplate
>     (https://github.com/vufind-org/vufind/tree/master/module/VuFindLocalTemplate
>     <https://github.com/vufind-org/vufind/tree/master/module/VuFindLocalTemplate>)
>     and change the namespace in its Module.php file?____
>
>     __ __
>
>     I would suggest that the next step to debugging is to figure out
>     whether any of your modules are loading at all – you can test this
>     by putting debug output in each module’s module.config.php and/or
>     Module.php.____
>
>     __ __
>
>     I hope this will help put you back on track, but if you’re still
>     stuck, please share your results and I’ll offer further suggestions!____
>
>     __ __
>
>     - Demian____
>
>     __ __
>
>     *From:*Marco Ferreri [mailto:[hidden email]
>     <mailto:[hidden email]>]
>     *Sent:* Thursday, July 06, 2017 8:56 AM
>     *To:* [hidden email]
>     <mailto:[hidden email]>
>     *Subject:* [VuFind-Tech] Fwd: Overriding an existing controller____
>
>     __ __
>
>     Hello Demian,____
>
>     __ __
>
>     Thanks for your quick answer but it did not fix my problem.____
>
>     __ __
>
>     Before I run it I executed set | grep VUF____
>
>     __ __
>
>     And this is what I have:____
>
>     __ __
>
>     VUFIND_HOME=/usr/local/vufind____
>
>     VUFIND_LOCAL_DIR=/usr/local/vufind/local____
>
>     VUFIND_LOCAL_MODULES=TestConsole,Test____
>
>     __ __
>
>     But the result for the import process was the same.____
>
>     __ __
>
>     Any other ideas?____
>
>     __ __
>
>     Thanks again.____
>
>     __ __
>
>     __ __
>
>     __ __
>
>     __ __
>
>     2017-07-06 14:04 GMT+02:00 Demian Katz <[hidden email]
>     <mailto:[hidden email]>>:____
>
>         Marco,____
>
>         ____
>
>         Environment variables need to be set up in two places – the
>         SetEnv in httpd-vufind.conf only applies in the context where
>         VuFind is executing through Apache (i.e. when you access it over
>         the web). If you are running from the command line, Apache is
>         not involved, so you need the variable set in your local shell
>         environment. Just run this before doing anything else:____
>
>         ____
>
>         export VUFIND_LOCAL_MODULES=Test,TestConsole____
>
>         ____
>
>         You can also add this line to /etc/profile.d/vufind.sh if you
>         want it to be set up by default whenever you start a new shell
>         session.____
>
>         ____
>
>         I suspect that this is the missing piece of the puzzle for you –
>         but please let me know if you are still having problems.____
>
>         ____
>
>         - Demian____
>
>         ____
>
>         *From:*Marco Ferreri [mailto:[hidden email]
>         <mailto:[hidden email]>]
>         *Sent:* Thursday, July 06, 2017 7:44 AM
>         *To:* [hidden email]
>         <mailto:[hidden email]>
>         *Subject:* [VuFind-Tech] Overriding an existing controller____
>
>         ____
>
>         Hello,____
>
>         ____
>
>         I am trying to override an existing controller of VuFindConsole
>         module. I have been reading the documentation for this page
>         https://vufind.org/wiki/development:plugins:controllers
>         <https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fvufind.org%2Fwiki%2Fdevelopment%3Aplugins%3Acontrollers&data=02%7C01%7Cdemian.katz%40villanova.edu%7C326d437aa6af420d79c808d4c464bbd2%7C765a8de5cf9444f09cafae5bf8cfa366%7C0%7C0%7C636349384320024728&sdata=YbwI2N0yBxK5yYLxEBJyfwjd2CvtHOC%2B3FmdLa6d35A%3D&reserved=0>____
>
>         but I can not override it correctly.____
>
>         ____
>
>         I have created two new local modules. In httpd-vufind.conf I
>         have this:____
>
>         ____
>
>         SetEnv VUFIND_LOCAL_MODULES Test, TestConsole____
>
>         ____
>
>         I also have these folders:____
>
>         ____
>
>         /usr/local/vufind/module/Test/src/Test/____
>
>         /usr/local/vufind/module/Test/config/____
>
>         /usr/local/vufind/module/TestConsole/src/TestConsole/____
>
>         /usr/local/vufind/module/TestConsole/config/____
>
>         ____
>
>         I have created the
>         class /usr/local/vufind/module/TestConsole/src/TestConsole/Controller/ImportController.php
>         ____
>
>         ____
>
>         ____
>
>         And I modified as this:____
>
>         ____
>
>         class ImportController extends
>         VuFindConsole\Controller\AbstractBase____
>
>         ____
>
>         And just to test I added a comment to the importXsl action____
>
>         ____
>
>              public function importXslAction()____
>
>              {____
>
>                      echo "NEW MODULE";____
>
>         ____
>
>         ____
>
>         In the original file
>         (/usr/local/vufind/module/VuFindConsole/src/VuFindConsole/Controller/ImportController.php)
>         I put this comment:____
>
>         ____
>
>              public function importXslAction()____
>
>              {____
>
>                      echo "ORIGINAL MODULE";____
>
>         ____
>
>         ____
>
>         I also updated the module.config.php file for TestConsole and
>         added these lines:____
>
>         ____
>
>         <?php____
>
>         namespace TestConsole\Module\Config;____
>
>         $config = [____
>
>              'controllers' => [____
>
>                  'invokables' => [____
>
>                      'import' =>
>         'TestConsole\Controller\ImportController',____
>
>                  ],____
>
>              ],____
>
>         ____
>
>         ];____
>
>         ____
>
>         return $config;____
>
>         ____
>
>         After doing this I deleted the cache directories for config and
>         objects.____
>
>         ____
>
>         To test it I run:____
>
>         ____
>
>         [root@Vdevtest vufind]#
>         /usr/local/vufind/harvest/batch-import-xsl.sh ./Metadata/
>         ../import/metadata.properties____
>
>         Processing
>         /usr/local/vufind/local/harvest/./Metadata//1499254912_metadata_10771_8371.xml
>         ...____
>
>         ORIGINAL MODULE____
>
>         ____
>
>         Is there somehing that I miss? ____
>
>         ____
>
>         I would like to be able to use the entire functionality of
>         VuFind and VufindConsole modules but taking into account the new
>         code from Test and TestConsole modules.____
>
>         ____
>
>         Thanks a lot for your help.____
>
>         ____
>
>         Regards,____
>
>         ____
>
>         Marco.____
>
>         ____
>
>         ____
>
>         ____
>
>     __ __
>
>     __ __
>
>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>
>
>
> _______________________________________________
> Vufind-tech mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/vufind-tech
>

--
Ere Maijala
Kansalliskirjasto / The National Library of Finland

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Fwd: Overriding an existing controller

Marco Ferreri
Hello,

Yes I did it running this script but unfortunatelly nothing changes.


rm -Rf /usr/local/vufind/local/cache/configs/*
rm -Rf /usr/local/vufind/local/cache/languages/*
rm -Rf /usr/local/vufind/local/cache/objects/*
rm -Rf /usr/local/vufind/local/cache/searchspecs/*
rm -Rf /usr/local/vufind/local/cache/cli/searchspecs/*
rm -Rf /usr/local/vufind/local/cache/cli/languages/*
rm -Rf /usr/local/vufind/local/cache/cli/objects/*
rm -Rf /usr/local/vufind/local/cache/cli/configs/*


Regards,


---------- Forwarded message ----------
From: Marco Ferreri <[hidden email]>
Date: 2017-07-07 12:54 GMT+02:00
Subject: Re: [VuFind-Tech] Overriding an existing controller
To: Ere Maijala <[hidden email]>


Hello Demain,

Yes I did it running this script but unfortunatelly nothing changes.


rm -Rf /usr/local/vufind/local/cache/configs/*
rm -Rf /usr/local/vufind/local/cache/languages/*
rm -Rf /usr/local/vufind/local/cache/objects/*
rm -Rf /usr/local/vufind/local/cache/searchspecs/*
rm -Rf /usr/local/vufind/local/cache/cli/searchspecs/*
rm -Rf /usr/local/vufind/local/cache/cli/languages/*
rm -Rf /usr/local/vufind/local/cache/cli/objects/*
rm -Rf /usr/local/vufind/local/cache/cli/configs/*


Regards,



2017-07-07 12:26 GMT+02:00 Ere Maijala <[hidden email]>:
One thing I've stumbled on a couple of times: unless you also set VUFIND_ENV to development in the terminal, the module configs etc. are cached in local/cache/cli (if my memory serves), and you have to manually delete the files under local/cache/cli. Not sure if you're affected, but something to be aware of!

--Ere

Marco Ferreri kirjoitti 7.7.2017 klo 13.08:
Hello Demian,

I am sorry but I have still with the problem.

I copied the files from VuFindLocalTemplate and  I changed the names later.

I am not an expert in Zend Framework and I do not know how to set this debug mode in the modules but I tried debugging the application.config.php file putting a print_r($modules) before the return line so anytime I execute the import command I see this:

Array
(
     [0] => ZfcRbac
     [1] => VuFindTheme
     [2] => VuFindSearch
     [3] => VuFind
     [4] => VuFindAdmin
     [5] => VuFindConsole
     [6] => Test
     [7] => TestConsole
)


So I believe I am using this module correctly but it is pointing to the VuFind Controller when I do the import.

Do you have any other idea to fix this?

Thanks a lot.




2017-07-06 15:00 GMT+02:00 Demian Katz <[hidden email] <mailto:[hidden email]>>:

    Marco,____

    __ __

    How did you create your local modules? Did you set them up using the
    install.php script, or did you build them manually? If you built
    them manually, did you copy the VuFindLocalTemplate
    (https://github.com/vufind-org/vufind/tree/master/module/VuFindLocalTemplate
    <https://github.com/vufind-org/vufind/tree/master/module/VuFindLocalTemplate>)
    and change the namespace in its Module.php file?____

    __ __

    I would suggest that the next step to debugging is to figure out
    whether any of your modules are loading at all – you can test this
    by putting debug output in each module’s module.config.php and/or
    Module.php.____

    __ __

    I hope this will help put you back on track, but if you’re still
    stuck, please share your results and I’ll offer further suggestions!____

    __ __

    - Demian____

    __ __

    *From:*Marco Ferreri [mailto:[hidden email]
    <mailto:[hidden email]>]
    *Sent:* Thursday, July 06, 2017 8:56 AM
    *To:* [hidden email]
    <mailto:[hidden email]>
    *Subject:* [VuFind-Tech] Fwd: Overriding an existing controller____

    __ __

    Hello Demian,____

    __ __

    Thanks for your quick answer but it did not fix my problem.____

    __ __

    Before I run it I executed set | grep VUF____

    __ __

    And this is what I have:____

    __ __

    VUFIND_HOME=/usr/local/vufind____

    VUFIND_LOCAL_DIR=/usr/local/vufind/local____

    VUFIND_LOCAL_MODULES=TestConsole,Test____

    __ __

    But the result for the import process was the same.____

    __ __

    Any other ideas?____

    __ __

    Thanks again.____

    __ __

    __ __

    __ __

    __ __

    2017-07-06 14:04 GMT+02:00 Demian Katz <[hidden email]
    <mailto:[hidden email]>>:____

        Marco,____

        ____

        Environment variables need to be set up in two places – the
        SetEnv in httpd-vufind.conf only applies in the context where
        VuFind is executing through Apache (i.e. when you access it over
        the web). If you are running from the command line, Apache is
        not involved, so you need the variable set in your local shell
        environment. Just run this before doing anything else:____

        ____

        export VUFIND_LOCAL_MODULES=Test,TestConsole____

        ____

        You can also add this line to /etc/profile.d/vufind.sh if you
        want it to be set up by default whenever you start a new shell
        session.____

        ____

        I suspect that this is the missing piece of the puzzle for you –
        but please let me know if you are still having problems.____

        ____

        - Demian____

        ____

        *From:*Marco Ferreri [mailto:[hidden email]
        <mailto:[hidden email]>]
        *Sent:* Thursday, July 06, 2017 7:44 AM
        *To:* [hidden email]
        <mailto:[hidden email]>
        *Subject:* [VuFind-Tech] Overriding an existing controller____

        ____

        Hello,____

        ____

        I am trying to override an existing controller of VuFindConsole
        module. I have been reading the documentation for this page
        https://vufind.org/wiki/development:plugins:controllers
        <https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fvufind.org%2Fwiki%2Fdevelopment%3Aplugins%3Acontrollers&data=02%7C01%7Cdemian.katz%40villanova.edu%7C326d437aa6af420d79c808d4c464bbd2%7C765a8de5cf9444f09cafae5bf8cfa366%7C0%7C0%7C636349384320024728&sdata=YbwI2N0yBxK5yYLxEBJyfwjd2CvtHOC%2B3FmdLa6d35A%3D&reserved=0>____

        but I can not override it correctly.____

        ____

        I have created two new local modules. In httpd-vufind.conf I
        have this:____

        ____

        SetEnv VUFIND_LOCAL_MODULES Test, TestConsole____

        ____

        I also have these folders:____

        ____

        /usr/local/vufind/module/Test/src/Test/____

        /usr/local/vufind/module/Test/config/____

        /usr/local/vufind/module/TestConsole/src/TestConsole/____

        /usr/local/vufind/module/TestConsole/config/____

        ____

        I have created the
        class /usr/local/vufind/module/TestConsole/src/TestConsole/Controller/ImportController.php
        ____

        ____

        ____

        And I modified as this:____

        ____

        class ImportController extends
        VuFindConsole\Controller\AbstractBase____

        ____

        And just to test I added a comment to the importXsl action____

        ____

             public function importXslAction()____

             {____

                     echo "NEW MODULE";____

        ____

        ____

        In the original file
        (/usr/local/vufind/module/VuFindConsole/src/VuFindConsole/Controller/ImportController.php)
        I put this comment:____

        ____

             public function importXslAction()____

             {____

                     echo "ORIGINAL MODULE";____

        ____

        ____

        I also updated the module.config.php file for TestConsole and
        added these lines:____

        ____

        <?php____

        namespace TestConsole\Module\Config;____

        $config = [____

             'controllers' => [____

                 'invokables' => [____

                     'import' =>
        'TestConsole\Controller\ImportController',____

                 ],____

             ],____

        ____

        ];____

        ____

        return $config;____

        ____

        After doing this I deleted the cache directories for config and
        objects.____

        ____

        To test it I run:____

        ____

        [root@Vdevtest vufind]#
        /usr/local/vufind/harvest/batch-import-xsl.sh ./Metadata/
        ../import/metadata.properties____

        Processing
        /usr/local/vufind/local/harvest/./Metadata//1499254912_metadata_10771_8371.xml
        ...____

        ORIGINAL MODULE____

        ____

        Is there somehing that I miss? ____

        ____

        I would like to be able to use the entire functionality of
        VuFind and VufindConsole modules but taking into account the new
        code from Test and TestConsole modules.____

        ____

        Thanks a lot for your help.____

        ____

        Regards,____

        ____

        Marco.____

        ____

        ____

        ____

    __ __

    __ __




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot



_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech


--
Ere Maijala
Kansalliskirjasto / The National Library of Finland

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Overriding an existing controller

Demian Katz
In reply to this post by Marco Ferreri

Yes, the module list certainly looks correct.


There's no specific debug mode you need to set, but I was suggesting it might be helpful to add


echo "entering Module.php\n";


somewhere in module/TestConsole/Module.php, and


echo "entering module.config.php\n";


somewhere in module/TestConsole/config/module.config.php


just to narrow down whether those two important parts of the puzzle were being loaded properly. That will tell us whether the problem has to do with the module failing to initialize correctly, or if the problem has to do with some detail of the actual configuration.


- Demian




From: Marco Ferreri <[hidden email]>
Sent: Friday, July 7, 2017 6:08 AM
Cc: [hidden email]
Subject: Re: [VuFind-Tech] Overriding an existing controller
 
Hello Demian,

I am sorry but I have still with the problem.

I copied the files from VuFindLocalTemplate and  I changed the names later.

I am not an expert in Zend Framework and I do not know how to set this debug mode in the modules but I tried debugging the application.config.php file putting a print_r($modules) before the return line so anytime I execute the import command I see this:

Array
(
    [0] => ZfcRbac
    [1] => VuFindTheme
    [2] => VuFindSearch
    [3] => VuFind
    [4] => VuFindAdmin
    [5] => VuFindConsole
    [6] => Test
    [7] => TestConsole
)


So I believe I am using this module correctly but it is pointing to the VuFind Controller when I do the import.

Do you have any other idea to fix this?

Thanks a lot.




2017-07-06 15:00 GMT+02:00 Demian Katz <[hidden email]>:

Marco,

 

How did you create your local modules? Did you set them up using the install.php script, or did you build them manually? If you built them manually, did you copy the VuFindLocalTemplate (https://github.com/vufind-org/vufind/tree/master/module/VuFindLocalTemplate) and change the namespace in its Module.php file?

 

I would suggest that the next step to debugging is to figure out whether any of your modules are loading at all – you can test this by putting debug output in each module’s module.config.php and/or Module.php.

 

I hope this will help put you back on track, but if you’re still stuck, please share your results and I’ll offer further suggestions!

 

- Demian

 

From: Marco Ferreri [mailto:[hidden email]]
Sent: Thursday, July 06, 2017 8:56 AM
To: [hidden email]
Subject: [VuFind-Tech] Fwd: Overriding an existing controller

 

Hello Demian,

 

Thanks for your quick answer but it did not fix my problem.

 

Before I run it I executed set | grep VUF

 

And this is what I have:

 

VUFIND_HOME=/usr/local/vufind

VUFIND_LOCAL_DIR=/usr/local/vufind/local

VUFIND_LOCAL_MODULES=TestConsole,Test

 

But the result for the import process was the same.

 

Any other ideas?

 

Thanks again.

 

 

 

 

2017-07-06 14:04 GMT+02:00 Demian Katz <[hidden email]>:

Marco,

 

Environment variables need to be set up in two places – the SetEnv in httpd-vufind.conf only applies in the context where VuFind is executing through Apache (i.e. when you access it over the web). If you are running from the command line, Apache is not involved, so you need the variable set in your local shell environment. Just run this before doing anything else:

 

export VUFIND_LOCAL_MODULES=Test,TestConsole

 

You can also add this line to /etc/profile.d/vufind.sh if you want it to be set up by default whenever you start a new shell session.

 

I suspect that this is the missing piece of the puzzle for you – but please let me know if you are still having problems.

 

- Demian

 

From: Marco Ferreri [mailto:[hidden email]]
Sent: Thursday, July 06, 2017 7:44 AM
To: [hidden email]
Subject: [VuFind-Tech] Overriding an existing controller

 

Hello,

 

I am trying to override an existing controller of VuFindConsole module. I have been reading the documentation for this page https://vufind.org/wiki/development:plugins:controllers

but I can not override it correctly.

 

I have created two new local modules. In httpd-vufind.conf I have this:

 

SetEnv VUFIND_LOCAL_MODULES Test, TestConsole

 

I also have these folders:

 

/usr/local/vufind/module/Test/src/Test/

/usr/local/vufind/module/Test/config/

/usr/local/vufind/module/TestConsole/src/TestConsole/

/usr/local/vufind/module/TestConsole/config/

 

I have created the class /usr/local/vufind/module/TestConsole/src/TestConsole/Controller/ImportController.php 

 

 

And I modified as this:

 

class ImportController extends VuFindConsole\Controller\AbstractBase

 

And just to test I added a comment to the importXsl action

 

    public function importXslAction()

    {

            echo "NEW MODULE";

 

 

In the original file (/usr/local/vufind/module/VuFindConsole/src/VuFindConsole/Controller/ImportController.php) I put this comment:

 

    public function importXslAction()

    {

            echo "ORIGINAL MODULE";

 

 

I also updated the module.config.php file for TestConsole and added these lines:

 

<?php

namespace TestConsole\Module\Config;

$config = [

    'controllers' => [

        'invokables' => [

            'import' => 'TestConsole\Controller\ImportController',

        ],

    ],

 

];

 

return $config;

 

After doing this I deleted the cache directories for config and objects.

 

To test it I run:

 

[root@Vdevtest vufind]# /usr/local/vufind/harvest/batch-import-xsl.sh ./Metadata/ ../import/metadata.properties

Processing /usr/local/vufind/local/harvest/./Metadata//1499254912_metadata_10771_8371.xml ...

ORIGINAL MODULE

 

Is there somehing that I miss? 

 

I would like to be able to use the entire functionality of VuFind and VufindConsole modules but taking into account the new code from Test and TestConsole modules.

 

Thanks a lot for your help.

 

Regards,

 

Marco.

 

 

 

 

 



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Vufind-tech mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-tech
Loading...