[TYPO3-mvc] extending tx_news with own object SOLVED

Johannes C. Schulz - EnzephaloN IT-Solutions info at enzephalon.de
Wed Jun 5 14:58:59 CEST 2013


Jippiee!
I got it!

After some difficulties I saw the uids inside the newsItem. After that some ugly codelines later, I did it:
class Tx_Psoabilling_Domain_Model_NewsDefault extends Tx_News_Domain_Model_NewsDefault{
	/**
	* @var \EnzephaloN\Psoabilling\Domain\Repository\BandRepository
	*/
	protected $bandRepository;
	/**
	 * Dependecy Injection of the Band Repository
	 * @param \EnzephaloN\Psoabilling\Domain\Repository\BandRepository $bandRepository
	 * @return void
	 */
	public function injectBandRepository(\EnzephaloN\Psoabilling\Domain\Repository\BandRepository $bandRepository){
		$this->bandRepository = $bandRepository;
	}
  /**
   * @var string
   * @lazy
  */
  protected $psoabilling;
  /**
	* The constructor.
	* @return void
	*/
	public function __construct() {
		$this->psoabilling = $this->objectManager->get('EnzephaloN\\Psoabilling\\Domain\\Model\\Band');
	}  
  /**
   * @return array
   */
  public function getPsoabilling(){
  	$uids = array();
  	$bands = array();
    $uids = explode(",",$this->psoabilling);
    foreach($uids as $uid){
    	$bands[] = $this->bandRepository->findByUid($uid);
    }
    return $bands;
  }
}

Best regards and many thanks for some hints.
Johannes


-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von Johannes C. Schulz - EnzephaloN IT-Solutions
Gesendet: Mittwoch, 5. Juni 2013 14:15
An: 'TYPO3 v4 MVC project'
Betreff: Re: [TYPO3-mvc] extending tx_news with own object

After some tryings I hope it's going forward.
No I have an error-trace where I can see my object and assigned values. 

But I don't know how to fix the thrown error:
Could not find class definition for name "TYPO3\CMS\Extbase\Object\ObjectManagerInterface". This could be caused by a mis-spelling of the class name in the class definition.

[edit]: ups, forget to link to the trace-picture: http://www.enzephalon.de/fileadmin/pics/could_not_find_class_definition.jpg

Any ideas?
Johannes

-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von Johannes C. Schulz - EnzephaloN IT-Solutions
Gesendet: Mittwoch, 5. Juni 2013 13:03
An: 'TYPO3 v4 MVC project'
Betreff: Re: [TYPO3-mvc] extending tx_news with own object

Again me, sorry fort hat...
I wrote down some crap inside Psoabilling/Classes/Domain/Model/News.php and NO error was thrown. Ergo: The tx_news-extending-class isn't loaded. I wrote the howto of Georg several times and found nothing about this.
Can someone help me please?

Johannes


-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von Johannes C. Schulz - EnzephaloN IT-Solutions
Gesendet: Mittwoch, 5. Juni 2013 12:17
An: 'TYPO3 v4 MVC project'
Betreff: Re: [TYPO3-mvc] extending tx_news with own object

Again I do a try to ask:

If I write a class like
class Tx_Psoabilling_Domain_Model_News extends Tx_News_Domain_Model_News{
/**
   * @var Tx_Extbase_Persistence_ObjectStorage<Tx_Psoabilling_Domain_Model_Band>
   * @lazy
   */
protected $psoabilling;
[...]

I think this will add the property "psoabilling" to a newsItem?! But whats the problem, if psoabilling doesn't appear in newsItem? I hope/think that’s the first failure to solve.

Johannes

-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von Johannes C. Schulz [EnzephaloN IT-Solutions]
Gesendet: Mittwoch, 5. Juni 2013 10:00
An: TYPO3 v4 MVC project
Betreff: Re: [TYPO3-mvc] extending tx_news with own object

Some more question

Maxbe it doesn't work cause of mixing namespaces an Tx_-notation?

My psoabilling-extension uses namespaces: Enzephalon\Domain\Model\Band And the news-extending now uses Tx_-nitation:
Tx_Psoabilling_Domain_Model_News

Is this right??

Viele Grüße
Johannes C. Schulz -  EnzephaloN IT-Solutions (von unterwegs gesendet)



"Johannes C. Schulz - EnzephaloN IT-Solutions" <info at enzephalon.de> schrieb:
>Hello again
>
>I re-wrote my News-Model, without using namespaces hoping this will 
>work.
>But sadly it doesn't. Here it comes:
>class Tx_Psoabilling_Domain_Model_News extends 
>Tx_News_Domain_Model_NewsDefault{
>  /**
>   * @var
>Tx_Extbase_Persistence_ObjectStorage<Tx_Psoabilling_Domain_Model_Band>
>   * @lazy
>   */
>  protected $psoabilling;
>	  /**
>	* The constructor.
>	* @return void
>	*/
>	public function __construct() {
>		$this->psoabilling = new
>Tx_Extbase_Persistence_ObjectStorage();
>	}
>  /**
>   * @param Tx_Extbase_Persistence_ObjectStorage $psoabilling
>   * @return void
>   */
>  public function setPsoabilling(Tx_Extbase_Persistence_ObjectStorage
>$psoabilling){
>    $this->psoabilling = $psoabilling;
>  }
>  /**
>   * @return Tx_Extbase_Persistence_ObjectStorage
>   */
>  public function getPsoabilling(){
>    return $this->psoabilling;
>  }
>}
>
>After reading
>http://docs.typo3.org/typo3cms/extensions/news/Main/Tutorial/ExtendingN
>ews/I
>ndex.html and
>http://keinerweiss.de/525-die-extbase-extension-news-um-ein-feld-erweit
>ern.h tml I thought I know enough to hook the news-model.
>
>Can anyone give me hints to work forward with my news-extending hook?
>
>Best regards
>Johannes
>
>-----Ursprüngliche Nachricht-----
>Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org
>[mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag 
>von Johannes C. Schulz - EnzephaloN IT-Solutions
>Gesendet: Mittwoch, 5. Juni 2013 07:53
>An: 'TYPO3 v4 MVC project'
>Betreff: Re: [TYPO3-mvc] extending tx_news with own object
>
>Hello Eike
>
>|This should be class News extends \Tx_News_Domain_Model_NewsDefault{
>|Otherwise the Mapper would look at
>|Enzephalon\Psoabilling\Domain\Model\Tx_News_Domain_Model_NewsDefault
>
>I think that's the same as in my model.
>
>|Shouldn't it be Tx_Psoabilling_Domain_Model_News =
>Tx_Psoabilling_Domain_Model_News
>|And recordType = Tx_Psoabilling_Domain_Model_News, if you want to use
>recordType.
>|Now you have a type of news called Tx_Psoabilling_Domain_Model_News
>
>It's like my TS, just with "other words". But I tried your way. No 
>change.
>
>|Is psoabilling there when you use <f:debug>{newsItem}</f:debug>?
>
>No, there is no psoabilling inside of newsItem.
>
>|The problem could also be that the repository does not look for the
>right
>type Tx_Psoabilling_Domain_Model_News.
>
>Do you have any idea, how to fix this?
>
>Thanks a lot
>Johannes
>
>
>_______________________________________________
>TYPO3-project-typo3v4mvc mailing list
>TYPO3-project-typo3v4mvc at lists.typo3.org
>http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mv
>c
>
>
>_______________________________________________
>TYPO3-project-typo3v4mvc mailing list
>TYPO3-project-typo3v4mvc at lists.typo3.org
>http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mv
>c
_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc

_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc

_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc

_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc



More information about the TYPO3-project-typo3v4mvc mailing list