admin generator doesn't generate a class - php

Hi
I'm using symfony 1.2.7 with Doctrine.
Tryng to port a plugin originally written with Propel, but running into problems.
In one of the plugins modules the generator.yml starts like:
generator:
class: sfDoctrineGenerator
param:
model_class: Page
theme: admin
I always get "Fatal error: Class 'cmsPageGeneratorConfiguration' not found in .../cache/backend/dev/modules/autoCmsPage/actions/actions.class.php on line 18" I googled on it, but unlike my case anybody else seems like to missing the Base*GeneratorConfiguration class which is in it's place for me.
If i write something else to the theme directive the error goes away but the config is ignored, and the default forms and lists are shown, can't set even a title...
Why isn't the missing class auto-generated as it's supposed? I'm really stuck here, thanks in advance for any help.

I'm not familiar with this SF version, but did you try to clear the cache?
php symfony cc
This worked for me with similar error messages.

Related

template inheritance of overrided bundle

I am using symfony 3.4, but planning to update 4.0 in future.
So I reduce the bundle override step by step. ( it is prohibited in symfony 4)
For now I am planning to use template override in templtes directoly.
So I made the file here.
/templates/bundles/ApplicationSonataMediaBundle/Form/media_widgets.html
then cache clear
php app/console cache:clear
However it doesn't work.
My error messages are like this below.
Unable to find template "ApplicationSonataMediaBundle:Form:media_widgets.html.twig"
(looked into: /Users/whitebear/CodingWorks/httproot/myapp/vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views,
/Users/whitebear/CodingWorks/httproot/myapp/app/Resources/views,
/Users/whitebear/CodingWorks/httproot/myapp/templates,
/Users/whitebear/CodingWorks/httproot/myapp/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form).
Where should I check next??
your error message suggests, you have a call
$this->render('ApplicationSonataMediaBundle:Form:media_widgets.html.twig');
somewhere (plus parameters). That syntax isn't used anymore, instead use:
$this->render('#ApplicationSonataMediaBundle/Form/media_widgets.html.twig');
as shown in the Symfony templating docs (it appears this changed from symfony 3.1 to 3.2, if the docs can be trusted).

How to mock, use or override Environment::isCli() in TYPO3 v9 unit tests

I'm trying to get a TYPO3 v8 system updated to TYPO3 v9, but when it comes to unit-testing, I got some errors. I was able to fix some of them on my own but this one here's a very difficult one for me, because unit-testing is somewhat new to me in general.
I already searched the web, the TYPO3 documentation (which seems like the important parts are missing?), asked some friends and tried some things on my own, but nothing helped.
$this->environmentMock = $this->createMock(Environment::class);
$this->environmentMock->expects($this->once())
->method("::isCli")
->will($this->returnValue(TRUE));
I'm expecting to manually override the static function ::isCli() that comes with the Environment class. If that's not possible, is there any other "workaround", like setting a protected variable or something like that?
Currently this is my error message:
Trying to configure method "::isCli" which cannot be configured because it does not exist, has not been specified, is final, or is static
Thanks in advance!
Update 1:
After using #susis tip, I get the following error when appending the code:
TypeError: Return value of TYPO3\CMS\Core\Core\Environment::getContext() must be an instance of TYPO3\CMS\Core\Core\ApplicationContext, null returned
Additional information: My project is just an extension folder with TYPO3 v9 sources required in its own composer.json. No web, no htdocs, just the extension folder.
Update 2:
Here's a full gist of my test file.
Update 3:
Even the debugger isn't helping me in this case, see attached screenshot:
xdebug phpstorm applicationcontext environment screenshot
Update 4:
I updated the gist, added the environment vars to the phpunit.xml file and added parent::setUp() to the top of the setUp() method but the error is still the same:
TypeError : Return value of TYPO3\CMS\Core\Core\Environment::getContext() must be an instance of TYPO3\CMS\Core\Core\ApplicationContext, null returned
/Users/xyz/my_redirect/public/typo3/sysext/core/Classes/Core/Environment.php:97
/Users/xyz/my_redirect/Tests/Unit/Hooks/RequestHandlerHookTest.php:41
Update 5:
I updated the gist and removed the environment settings from the phpunit.xml due to what I've seen that they didn't work either. At this moment, the test is working but I'm still not sure if it's done the right way. Thanks for your help!
You can initialize the Environment you want in your tests, for example with:
Environment::initialize(
Environment::getContext(),
true,
false,
Environment::getProjectPath(),
Environment::getPublicPath(),
Environment::getVarPath(),
Environment::getConfigPath(),
Environment::getBackendPath() . '/index.php',
Environment::isWindows() ? 'WINDOWS' : 'UNIX'
);
This is the same way as it is done in TYPO3 Core tests and allows you to customize the complete environment. If you are using the TYPO3 testing framework / UnitTestCase base classes, you can use the property protected $backupEnvironment = true; to make sure the environment is reset after your test.
For an example, you can have a look at the ResourceCompressorIntegrationTest

SilverStripe 4 - DataExtension auto-publish versioned files error

As stated by this solution, the workaround proposed works very well on dev and test SS environments.
The suggested one is to avoid the current bug related to auto-publish files managed via DataObject $owns property.
But since I uploaded my project in production - on live env - the workaround doesn't work anymore.
In my case I'm working on a DataExtension of User model. The rest of implementation follows exactly the above mentioned case - with UploadField.
In production, it seems that the snippet is ignored in its condition. In particular, this is my version:
UserExtension
// AllegatiDownload: many_many File type uploaded with UploadField
public function onAfterWrite()
{
if ($this->owner->AllegatiDownloadID) { // <- This is being ignored in live version
$this->owner->AllegatiDownload()->publishSingle();
}
parent::onAfterWrite();
}
If I try to replace
$this->owner->AllegatiDownloadID
with
$this->owner->AllegatiDownload()
The condition pass, but $this->owner->AllegatiDownload()->publishSingle() returns an untraced 500 exception. Just:
There was been an error
And, as I said, this happens only in production.
Thanks in advance for support.
Today I flushed the project DB in order to upgrade a custom front-end component that interacts with it. Seems that after that flush, the issue being solved. That's pretty strange, because I tried many /dev/build?flush=all before, and nothing happened. Server cache maybe? I don't know. But now the workaround works as expected.
Thanks anyway for the support.

removing reference to googlesitemaps in silverstripe

I've recently moved a silverstripe site to a new server. Since then it's bringing up the error:
Fatal error: Class 'SiteTreeDecorator' not found in /home/priorysc/public_html/googlesitemaps/code/GoogleSitemapDecorator.php on line 9
I try removing the googlesitemaps folder, but then it just brings up the error that it can't find the googlesitemaps _config file. Is there any way I can remove the reference to googlesitemaps, or failing that just get the thing to work?
I'm a fairly verse php coder but I don't know that much about silverstripe as it's just been dumped on me.
Anyone know? I'm tearing my hair out over this!
-James
SiteTreeDecorator was a class that existed in v2.4 of SilverStripe, the fact that the error is saying it doesn't exist tells me you're running v3.0 or higher. Double check which version of SilverStripe you're running, then update the 'googlesitemaps' module to the appropriate version:
SilverStripe v3.0: https://github.com/silverstripe-labs/silverstripe-googlesitemaps/tree/1.1
SilverStripe v3.1: https://github.com/silverstripe-labs/silverstripe-googlesitemaps/tree/master

Class sfDoctrineRouteCollection not found

I'm starting a new project using SF 1.4.18 and sfDoctrine & sfDoctrineGuard plugins. I had both active at config/ProjectConfiguration.class.php as follow:
public function setup() {
$this->enablePlugins(
array(
'sfDoctrinePlugin',
'sfDoctrineGuardPlugin'
)
);
}
All is good so far but when I try to reach the URL http://inventario.devserver/backend_dev.php/sfGuardUser this error come up:
Fatal error: Class 'sfDoctrineRouteCollection' not found in /var/www/html/inventario
/plugins/sfDoctrineGuardPlugin/lib/routing/sfGuardRouting.class.php on line 59
I don't know what's causing the error because I follow every step at plugins docs. Any help or advice?
Symfony 1.4 is shipped with sfDoctrinePlugin. You shouldn't add the plugin on your own.
Remove the folder sfDoctrinePlugin from your /plugins folder, clear your cache and it will solve your issue.
It's exactly the same problem from this guy, on the official Symfony forum, in 2009.

Categories