[TYPO3-dev] A problem using image manipulation in my own class file

Martin Kutschker masi-no at spam-typo3.org
Wed Nov 19 12:03:26 CET 2008


Tapio Markula schrieb:
> Martin Kutschker
>>> Hi
>>>
>>>
>>> I have
>>>
>>>
>>> require_once ( $t3lib_PATH . 'class.t3lib_stdgraphic.php' );
>>> class returnContent extends t3lib_stdGraphic {
>>>     function main() {
>>>
>>> ...
>>>
>>> }
>>> $content=returnContent::main();
>>>               
>>> $imgFile=t3lib_stdGraphic::imageMagickConvert($image,'jpg','270');
>>>
>>> Fatal error: Using $this when not in object context in
>>> /home/tapio/public_html/typo3_4.2.0dev/t3lib/class.t3lib_stdgraphic.php
>>> on line 2130
>>>
>>> if
>>>
>>> $imgFile=$this->imageMagickConvert($image,'jpg','270');
>>>
>>> Fatal error: Using $this when not in object context in
>>> /home/tapio/public_html/fileadmin/ext-templates/myincludes.inc on
>>> line 50
>>
>> You must instantiate your class with "new". stdGraphic is not designed
>> to be used with static method calls. Note also that stdGraphic has init
>> functions that need to be called first before you can access its other
>> methods.
> 
> 
> Sorry I'm not familiar with these kinds of core classes.

I don't want to offend you, but try and learn a bit about object
oriented programming in general and how objects and classes work in PHP.
The docs on php.net may be a starter.

> 
> Tried
> 
> 
> require_once ( PATH_site . 't3lib/class.t3lib_stdgraphic.php' );
> class ux_t3lib_stdGraphic {
>     
>     function main() {
>         global $BE_USER,$LANG,$typo3GET,$content;
>         $graphObjBase =
> t3lib_div::makeInstanceClassName('t3lib_stdGraphic');
>         $graphObj = new $graphObjBase;
>         $graphObj->init();

If you extent a class you don't need to instiate the base class.

require_once ( PATH_site . 't3lib/class.t3lib_stdgraphic.php' );
class ux_t3lib_stdGraphic {

function main() {
        $this->init();
        // your stuff
}

Masi




More information about the TYPO3-dev mailing list