Discussion:
[TYPO3-english] problem after update to 6.2 with extension
Andreas Pfeiffer
2014-03-26 14:15:42 UTC
Permalink
hi,

i have written an extension based on extbase, fluid and namespace.

everything worked with TYPO3 6.1.7

after the update i get the follwoing message

http://relaunch.crazy-twins.de/projekte/ajax.html?file=sidebar

"*Could not find class definition for name
"Ct\CtGallery\Domain\Model\Picture". This could be caused by a mis-spelling
of the class name in the class definition.*

TYPO3\CMS\Extbase\Persistence\Generic\Exception\InvalidClassException thrown
in file
/var/www/vhosts/
crazy-twins.de/httpdocs/__relaunch.crazy-twins.de/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapFactory.php
in
line 102."

has someone a hint why?

thanks.
Philipp Gampe
2014-03-26 19:43:31 UTC
Permalink
Hi Andreas,
Post by Andreas Pfeiffer
"*Could not find class definition for name
"Ct\CtGallery\Domain\Model\Picture". This could be caused by a
mis-spelling of the class name in the class definition.*
Did you clear all caches via the install tool?

Best regards
--
Philipp Gampe ? PGP-Key 0AD96065 ? TYPO3 UG Bonn/K?ln
Documentation ? Active contributor TYPO3 CMS
TYPO3 .... inspiring people to share!
andreas
2014-03-26 21:29:57 UTC
Permalink
hi philipp,
Post by Philipp Gampe
Did you clear all caches via the install tool?
yes, i have cleared them, i deleted the cache-files from typo3temp too, checked the naming of all the classes.

i do not know where the mistake shall be.

i have reduced the controller to the minimum:

<?php
namespace Ct\CtGallery\Controller;

class PictureController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {

/**
* pictureRepository
*
* @var \Ct\CtGallery\Domain\Repository\PictureRepository
* @inject
*/
protected $pictureRepository;

/**
* categoryRepository
*
* @var \Ct\CtGallery\Domain\Repository\CategoryRepository
* @inject
*/
protected $categoryRepository;

/**
* injectPictureRepository
*
* @param \Ct\CtGallery\Domain\Repository\PictureRepository $pictureRepository
* @return void
*/
public function injectPictureRepository(\Ct\CtGallery\Domain\Repository\PictureRepository $pictureRepository) {
$this->pictureRepository = $pictureRepository;
}

/**
* injectCategoryRepository
*
* @param \Ct\CtGallery\Domain\Repository\CategoryRepository $categoryRepository
* @return void
*/
public function injectCategoryRepository(\Ct\CtGallery\Domain\Repository\CategoryRepository $categoryRepository) {
$this->categoryRepository = $categoryRepository;
}

/**
* action list
*
* @return void
*/
public function listAction() {
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($this->categoryRepository->findByUid(12));
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($this->pictureRepository->findByUid(12));
}
}
?>

he goes into the list action and the part with the categoryRepository works but not with the pictureRepository.

do you have an idea why?

regards andreas
Markus Klein
2014-03-26 22:13:15 UTC
Permalink
Hi!

So why do you have @inject and inject* methods?
Don't know if this breaks something or if this could work at all. Just looks a bit weird by reading.

Kind regards
Markus

------------------------------------------------------------
Markus Klein
TYPO3 CMS Active Contributors Team Member
-----Original Message-----
From: typo3-english-bounces at lists.typo3.org [mailto:typo3-english-
bounces at lists.typo3.org] On Behalf Of andreas
Sent: Wednesday, March 26, 2014 10:30 PM
To: typo3-english at lists.typo3.org
Subject: [TYPO3-english] Re: problem after update to 6.2 with extension
hi philipp,
Post by Philipp Gampe
Did you clear all caches via the install tool?
yes, i have cleared them, i deleted the cache-files from typo3temp too,
checked the naming of all the classes.
i do not know where the mistake shall be.
<?php
namespace Ct\CtGallery\Controller;
class PictureController extends
\TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
/**
* pictureRepository
*
*/
protected $pictureRepository;
/**
* categoryRepository
*
*/
protected $categoryRepository;
/**
* injectPictureRepository
*
$pictureRepository
*/
public function
injectPictureRepository(\Ct\CtGallery\Domain\Repository\PictureRepository
$pictureRepository) {
$this->pictureRepository = $pictureRepository;
}
/**
* injectCategoryRepository
*
$categoryRepository
*/
public function
injectCategoryRepository(\Ct\CtGallery\Domain\Repository\CategoryReposi
tory $categoryRepository) {
$this->categoryRepository = $categoryRepository;
}
/**
* action list
*
*/
public function listAction() {
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($this-
Post by Philipp Gampe
categoryRepository->findByUid(12));
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($this-
Post by Philipp Gampe
pictureRepository->findByUid(12));
}
}
?>
he goes into the list action and the part with the categoryRepository works
but not with the pictureRepository.
do you have an idea why?
regards andreas
_______________________________________________
TYPO3-english mailing list
TYPO3-english at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
andreas
2014-03-26 22:22:47 UTC
Permalink
hi markus,

i have read somewhere, that ist works like this with the injection of classes. also the extensionbuilder has set both.

well, i also tried to remove one of each and does not change something.

regrats andreas
andreas
2014-03-26 22:27:27 UTC
Permalink
hi markus,

you are right:

http://forge.typo3.org/projects/typo3v4-mvc/wiki/Dependency_Injection_(DI)

with 4.7 the function is not necessary. but that makes no difference.
Markus Klein
2014-03-26 22:58:32 UTC
Permalink
You should debug the classloader now.
Set a breakpoint in loadClass() and have a look what goes wrong.
Tell me which path it takes in this function and I'll try to help you further.

Kind regards
Markus

------------------------------------------------------------
Markus Klein
TYPO3 CMS Active Contributors Team Member
-----Original Message-----
From: typo3-english-bounces at lists.typo3.org [mailto:typo3-english-
bounces at lists.typo3.org] On Behalf Of andreas
Sent: Wednesday, March 26, 2014 11:27 PM
To: typo3-english at lists.typo3.org
Subject: [TYPO3-english] Re: problem after update to 6.2 with extension
hi markus,
http://forge.typo3.org/projects/typo3v4-
mvc/wiki/Dependency_Injection_(DI)
with 4.7 the function is not necessary. but that makes no difference.
_______________________________________________
TYPO3-english mailing list
TYPO3-english at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
andreas
2014-03-27 01:55:32 UTC
Permalink
hi,

thank you. well, there was missing somethingwhen i debug what you have suggested.

i do not know why, but after a while an deleting the cache several times it worked.

has not directly to do with that but in 6.2 is a problem with the follwoing "function"

public function preProcess(\TYPO3\CMS\Backend\View\PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row)

in 6.1.7 it worked well. i want make with this a preview of a content element. that works but when i inject a repository there, i get this message:

#1: PHP Catchable Fatal Error: Argument 1 passed to TYPO3\CMS\Extbase\Persistence\Repository::__construct() must be an instance of TYPO3\CMS\Extbase\Object\ObjectManagerInterface, none given, called in /var/www/vhosts/crazy-twins.de/httpdocs/__relaunch.crazy-twins.de/typo3/sysext/core/Classes/Utility/GeneralUtility.php on line 4280 and defined in /var/www/vhosts/crazy-twins.de/httpdocs/__relaunch.crazy-twins.de/typo3/sysext/extbase/Classes/Persistence/Repository.php line 89 (More information)

TYPO3\CMS\Core\Error\Exception thrown in file
/var/www/vhosts/crazy-twins.de/httpdocs/__relaunch.crazy-twins.de/typo3/sysext/core/Classes/Error/ErrorHandler.php in line 108.

thank you.
Markus Klein
2014-03-27 10:32:47 UTC
Permalink
Hi!
Post by andreas
hi,
thank you. well, there was missing somethingwhen i debug what you have suggested.
i do not know why, but after a while an deleting the cache several times it worked.
has not directly to do with that but in 6.2 is a problem with the follwoing "function"
public function preProcess(\TYPO3\CMS\Backend\View\PageLayoutView
&$parentObject, &$drawItem, &$headerContent, &$itemContent, array
&$row)
Fixed with: http://forge.typo3.org/issues/57367
Post by andreas
in 6.1.7 it worked well. i want make with this a preview of a content element.
#1: PHP Catchable Fatal Error: Argument 1 passed to
TYPO3\CMS\Extbase\Persistence\Repository::__construct() must be an
instance of TYPO3\CMS\Extbase\Object\ObjectManagerInterface, none
given, called in /var/www/vhosts/crazy-
twins.de/httpdocs/__relaunch.crazy-
twins.de/typo3/sysext/core/Classes/Utility/GeneralUtility.php on line 4280
and defined in /var/www/vhosts/crazy-
twins.de/httpdocs/__relaunch.crazy-
twins.de/typo3/sysext/extbase/Classes/Persistence/Repository.php line 89
(More information)
TYPO3\CMS\Core\Error\Exception thrown in file /var/www/vhosts/crazy-
twins.de/httpdocs/__relaunch.crazy-
twins.de/typo3/sysext/core/Classes/Error/ErrorHandler.php in line 108.
No idea here, sorry.
Post by andreas
thank you.
Kind regards
Markus

------------------------------------------------------------
Markus Klein
TYPO3 CMS Active Contributors Team Member
andreas
2014-03-27 15:41:20 UTC
Permalink
hi markus,

thank you for your help.

i have changed all your suggestion according to:

public function preProcess(\TYPO3\CMS\Backend\View\PageLayoutView $parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row)

i use this function/hook for a preview of content in the page module.

i can instance an object like

$fluidRenderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Fluid\View\StandaloneView');

and it works without a problem. but if i instance an oject from a repsoitory in this extension like

$bannerRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Ce\CeContent\Domain\Repository\BannerRepository');

it fails but the repository self is ok and works in frontend.

---

well, i could use

\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField()

but i do not get images with this, just the plain data from the db.

thanks
Markus Klein
2014-03-27 18:09:06 UTC
Permalink
Hi!
Post by andreas
hi markus,
thank you for your help.
public function preProcess(\TYPO3\CMS\Backend\View\PageLayoutView
$parentObject, &$drawItem, &$headerContent, &$itemContent, array
&$row)
i use this function/hook for a preview of content in the page module.
i can instance an object like
$fluidRenderer =
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Fluid\
View\StandaloneView');
and it works without a problem. but if i instance an oject from a repsoitory in
this extension like
$bannerRepository =
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Ce\CeContent\Do
main\Repository\BannerRepository');
That will not work!
Take a look at the constructor of this class. As the error message you posted before already told us, you're missing a required parameter for the constructor.
Signature of the constructor you inherit from the Extbase Repository class looks like:
public function __construct(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager);

So you need to give it the reference to the object manager in use.
Post by andreas
it fails but the repository self is ok and works in frontend.
---
well, i could use
\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField()
but i do not get images with this, just the plain data from the db.
Kind regards
Markus

------------------------------------------------------------
Markus Klein
TYPO3 CMS Active Contributors Team Member
andreas
2014-03-27 21:30:46 UTC
Permalink
well, i am not that deep in the code.

thank you for your help. it works for me like:

/**
* @var \TYPO3\CMS\Extbase\Object\ObjectManager
*/
protected $objectManager;

/**
* Constructor
*/
public function __construct() {
$this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
}

and with

$xyRepository = $this->objectManager->create('Ce\\CeContent\\Domain\\Repository\\xy'Repository');

i can get the data. nice. well, i begin to like 6.2.

thank you.
Markus Klein
2014-03-28 08:14:12 UTC
Permalink
Well, actually this is overhead again, since every Controller already has the object manager at hand.
Look into the AbstractController (the one your Controller is extending).

Btw: use $this->objectManager->get() instead of create() (create is deprecated since 6.1)

Still I'm wondering why @inject is not working for you.

Kind regards
Markus

------------------------------------------------------------
Markus Klein
TYPO3 CMS Active Contributors Team Member
-----Original Message-----
From: typo3-english-bounces at lists.typo3.org [mailto:typo3-english-
bounces at lists.typo3.org] On Behalf Of andreas
Sent: Thursday, March 27, 2014 10:31 PM
To: typo3-english at lists.typo3.org
Subject: [TYPO3-english] Re: problem after update to 6.2 with extension
well, i am not that deep in the code.
/**
*/
protected $objectManager;
/**
* Constructor
*/
public function __construct() {
$this->objectManager =
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbas
e\Object\ObjectManager');
}
and with
$xyRepository = $this->objectManager-
Post by andreas
create('Ce\\CeContent\\Domain\\Repository\\xy'Repository');
i can get the data. nice. well, i begin to like 6.2.
thank you.
_______________________________________________
TYPO3-english mailing list
TYPO3-english at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
andreas
2014-03-28 09:34:05 UTC
Permalink
thank you.

i may wrote wrong.

in the regular controller for actions or repositories to call other it works fine with inject. really nice.

but i have a problem in a hook.

---

namespace Ce\CeContent\Hooks;

class DrawItem implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface {

/**
* @var \TYPO3\CMS\Extbase\Object\ObjectManager
*/
protected $objectManager;

/**
* Constructor
*/
public function __construct() {
$this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
}

/**
* Disable rendering restrictions for contentelements
*
* @param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject
* @param $drawItem
* @param $headerContent
* @param $itemContent
* @param array $row
* @return void
*/
public function preProcess(\TYPO3\CMS\Backend\View\PageLayoutView $parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row) {
if(preg_match('/cecontent/', $row["CType"])) {
$drawItem = false;

$type = str_replace('cecontent_', '', $row["CType"]);

$template = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName('EXT:ce_content/Resources/Private/Templates/Backend/CMSLayoutHook/' . ucfirst($type) . '.html');
$content = $this->getContent($type, $row["uid"]);
$itemContent = $this->getItem($template, $content);
}
}

/**
* get item
*
* @param \string $template
* @param \array $content
* @return $item
*/
private function getItem($template, $content) {
if(is_file($template) && count($content)) {
// template fluid - laden
$fluidRenderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Fluid\View\StandaloneView');
$fluidRenderer->setFormat('html');
$fluidRenderer->setTemplatePathAndFilename($template);
$fluidRenderer->setLayoutRootPath(dirname($template));

// template fluid - mappen
$fluidRenderer->assign('content', $content);

return $fluidRenderer->render();
}
}

/**
* get content
*
* @param \string $type
* @param \int $uid
* @return $content
*/
private function getContent($type, $uid) {
// inject funktioniert nicht, deshalb ?ber objectmanager
$repository = $this->objectManager->get('Ce\\CeContent\\Domain\\Repository\\' . ucfirst($type) . 'Repository');
$content = $repository->findByTtContentUid($uid);

return $content;
}
}

---

i use this as preview for own contentelements in the page-view an call this file in localconf.php

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'][] = 'EXT:' . $_EXTKEY . '/Classes/Hooks/CMSLayoutHook.php:Ce\\CeContent\\Hooks\\DrawItem';

no matter what i try to inject if repository or the StandaloneView for fluid - does not work.

this problem is solved with your help by the objectmanager.

so in general it works.

thank you
Philipp Gampe
2014-03-28 11:15:53 UTC
Permalink
Hi andreas,
Post by andreas
i may wrote wrong.
in the regular controller for actions or repositories to call other it
works fine with inject. really nice.
but i have a problem in a hook.
Yes. The @inject methods only work for classes that are instantiated with
the object manager itself. Hooks are instantiated with the
GeneralUtility::makeInstance method.
Therefore the object manager does not work here and you have to create it
yourself.

I suggest that if you use legacy hooks, then you should use it just as a
wrapper to call a real extbase class.
$objectManager = GeneralUtility::makeInstance('...\ObjectManager');
$realHook = $objectManager->get('myClass', arg1, arg2);
$realHook->someMethod();

That way you can use the whole magic inside the real hook class.

Best regards
--
Philipp Gampe ? PGP-Key 0AD96065 ? TYPO3 UG Bonn/K?ln
Documentation ? Active contributor TYPO3 CMS
TYPO3 .... inspiring people to share!
andreas
2014-03-28 13:42:43 UTC
Permalink
ok, thank you.

that is good to know.

well, this is a different topicbut in all the browsers i use, chrome firefox or opera the "add new record" icon vanishs when i hover with the mouse. it appears in "web -> page" and then i have regular content on a page. the icon is there when i not hover and vanishs when i hover. like this it is not possible to create content on a page, onl yhwen i use the list-view.

i have not found something here http://forge.typo3.org/projects/typo3cms-core/issues

that is known?

regrats andreas
Philipp Gampe
2014-03-28 16:16:17 UTC
Permalink
Hi andreas,
Post by andreas
well, this is a different topicbut in all the browsers i use, chrome
firefox or opera the "add new record" icon vanishs when i hover with the
mouse. it appears in "web -> page" and then i have regular content on a
page. the icon is there when i not hover and vanishs when i hover. like
this it is not possible to create content on a page, onl yhwen i use the
list-view.
That does not happen for me. Do you by chance use the gridelements
extension? I remember that it did something like this.

Best regards
--
Philipp Gampe ? PGP-Key 0AD96065 ? TYPO3 UG Bonn/K?ln
Documentation ? Active contributor TYPO3 CMS
TYPO3 .... inspiring people to share!
Ralf-Rene Schröder
2014-03-28 17:54:23 UTC
Permalink
use the newest dev version of gridelements
AND
remove all files in typo3temp
Post by Philipp Gampe
Hi andreas,
Post by andreas
well, this is a different topicbut in all the browsers i use, chrome
firefox or opera the "add new record" icon vanishs when i hover with the
mouse. it appears in "web -> page" and then i have regular content on a
page. the icon is there when i not hover and vanishs when i hover. like
this it is not possible to create content on a page, onl yhwen i use the
list-view.
That does not happen for me. Do you by chance use the gridelements
extension? I remember that it did something like this.
Best regards
--
image[FORMAT] - Ralf-Ren? Schr?der
http://www.image-format.eu ... Wir geben Ihrem Image das richtige Format
Loading...