Zum Inhalt springen

Property fehler in extension

Erstellt am 17. September 2014 · 11 Antworten · letzte Antwort am 19. September 2014

Tags: Fluid, Frage

mic187 ·

Hallo,
ich habe ein problem mit meiner extension die ich gerade am erstellen bin.
Es kommt momentan immer folgende fehlermeldung wenn ich einen kommentar abgeben möchte.
The property "communityPosts" on the subject does not exist.

Das Steht in der Model/CommunityPostsComments

/**
 * CommunityPostsComments
 */
class CommunityPostsComments extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {

	 /**
	 * @var \IL\TextExtension\Domain\Model\CommunityCategory 
	 */
	protected $communityCategory;
	
	
	/**
	 * content
	 *
	 * @var string
	 */
	protected $content = '';

	/**
	 * author
	 *
	 * @var string
	 */
	protected $author = '';

	/**
	 * author
	 *
	 * @var \DateTime
	 */
	protected $date = '';
	

	/**
	 * communityUser
	 *
	 * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\IL\TextExtension\Domain\Model\CommunityUser>
	 */
	protected $communityUser = NULL;

	/**
	 * __construct
	 */
	public function __construct() {
		//Do not remove the next line: It would break the functionality
		$this->initStorageObjects();
	}

	/**
	 * Initializes all ObjectStorage properties
	 * Do not modify this method!
	 * It will be rewritten on each save in the extension builder
	 * You may modify the constructor of this class instead
	 *
	 * @return void
	 */
	protected function initStorageObjects() {
		$this->communityUser = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
		$this->communityCategory = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
		$this->date = new \DateTime();
	}
	
	
	/**
	 * Sets for date
	 *
	 * @param \DateTime $date
	 * @return void
	 */
	public function setDate(DateTime $date) {
		$this->date = $date;
	}

	/**
	 * Returns for date
	 *
	 *
	 * @return \DateTime
	 */
	public function getDate() {
		return $this->date;
	}

	/**
	 * Returns the content
	 *
	 * @return string $content
	 */
	public function getContent() {
		return $this->content;
	}

	/**
	 * Sets the content
	 *
	 * @param string $content
	 * @return void
	 */
	public function setContent($content) {
		$this->content = $content;
	}
	
	
	/**
	 * Returns the author
	 *
	 * @return string $author
	 */
	public function getAuthor() {
		return $this->author;
	}

	/**
	 * Sets the author
	 *
	 * @param string $author
	 * @return void
	 */
	public function setAuthor($author) {
		//$this->author = $author;
		$this->author = $GLOBALS['TSFE']->fe_user->user['username'];
	}

	/**
	 * Adds a communityCategory
	 *
	 * @param \IL\TextExtension\Domain\Model\CommunityCategory $communityCategory
	 * @return void
	 */
	public function addCommunityCategory(\IL\TextExtension\Domain\Model\CommunityCategory $communityCategory) {
		$this->communityCategory->attach($communityCategory);
	}
	
	

	/**
	 * Removes a communityCategory
	 *
	 * @param \IL\TextExtension\Domain\Model\CommunityCategory $communityCategoryToRemove The CommunityCategory to be removed
	 * @return void
	 */
	public function removeCommunityCategory(\IL\TextExtension\Domain\Model\CommunityCategory $communityCategoryToRemove) {
		$this->communityCategory->detach($communityCategoryToRemove);
	}
	

	/**
	 * Returns the communityCategory
	 *
	 * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
	 */
	public function getCommunityCategory() {
		return $this->communityCategory;
	}

	
	/**
	 * Sets the communityCategory
	 *
	 * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\IL\TextExtension\Domain\Model\CommunityCategory> $communityCategory
	 * @return void
	 */
	public function setCommunityCategory(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $communityCategory) {
		$this->communityCategory = $communityCategory;
	}
	
	
/**
	 * Adds a CommunityPostsComments
	 *
	 * @param \IL\TextExtension\Domain\Model\CommunityPostsComments $communityPostsComment
	 * @return void
	 */
	public function addCommunityPostsComment(\IL\TextExtension\Domain\Model\CommunityPostsComments $communityPostsComment) {
		$this->communityPostsComments->attach($communityPostsComment);
	}

	/**
	 * Removes a CommunityPostsComments
	 *
	 * @param \IL\TextExtension\Domain\Model\CommunityPostsComments $communityPostsCommentToRemove The CommunityPostsComments to be removed
	 * @return void
	 */
	public function removeCommunityPostsComment(\IL\TextExtension\Domain\Model\CommunityPostsComments $communityPostsCommentToRemove) {
		$this->communityPostsComments->detach($communityPostsCommentToRemove);
	}

	/**
	 * Returns the communityPostsComments
	 *
	 * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\IL\TextExtension\Domain\Model\CommunityPostsComments> $communityPostsComments
	 */
	public function getCommunityPostsComments() {
		return $this->communityPostsComments;
	}

	/**
	 * Sets the communityPostsComments
	 *
	 * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\IL\TextExtension\Domain\Model\CommunityPostsComments> $communityPostsComments
	 * @return void
	 */
	public function setCommunityPostsComments(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $communityPostsComments) {
		$this->communityPostsComments = $communityPostsComments;
	}

Das Steht in dem Controller

/**
 * CommunityPostsCommentsController
 */
class CommunityPostsCommentsController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {

/**
	 * communityPostsCommentsRepository
	 *
	 * @var \IL\TextExtension\Domain\Repository\CommunityPostsCommentsRepository
	 * @inject
	 */
	protected $communityPostsCommentsRepository;
	

	/**
	 * action create
	 *
	 * @param \IL\TextExtension\Domain\Model\CommunityPostsComments $newCommunityPostsComments
	 * @return void
	 */
	public function createAction(\IL\TextExtension\Domain\Model\CommunityPostsComments $newCommunityPostsComments) {
		$this->addFlashMessage('Kommentar gepostet', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR);
		
		$this->communityPostsCommentsRepository->add($newCommunityPostsComments);
		$this->redirect('show', 'CommunityPosts', NULL, array('communityPosts' => $communityPosts, 'communityCategory' => $this->request->getArgument('communityCategory')));
	}

Und so sieht noch der template auschnitt aus

        <f:form action="create" enctype="multipart/form-data" objectName="newCommunityPostsComments" object="newCommunityPostsComments" method="post" controller="CommunityPostsComments" arguments="{communityPosts : communityPosts, communityCategory : communityCategory}">

	<div class="comments"><f:form.textarea property="content" rows="15" /></div>
	<f:form.hidden property="author" value="{contentauthor}"/>
    	<f:form.submit class="button" value="Kommentar posten"><input class="button" type="submit" name="" value="Submit" /></f:form.submit>
</f:form>

Hoffe es kann mir jemand helfen.

OnkelEdi ·

Hallo mic187,

ich bin mir nicht sicher, aber ich glaub das Problem liegt in der Zeile 25. Ich nehme an bei

array('communityPosts' => $communityPosts,...

Wenn ich das richtig verstanden habe, kommen Category und Post aus dem Formular und sollen an das Array übergeben haben. Du hast aber nur Category aus dem Request geholt:

$this->request->getArgument('communityCategory')

vielleicht jetzt noch das:

'communityPosts' => $communityPosts,

im Array mit dem hier austauschen:

'communityPosts' => $this->request->getArgument('communityPosts'),

Vielleicht kommen noch andere Fehler dazu, aber das ist mir jetzt als erstes aufgefallen.

Gruß
Eduard

Edit: Außerdem hast du im Model keine "communityPosts" oder? Meinst du vielleicht "communityPostsComments"?
Kann das vielleicht auch noch was sein, oder lieg ich da falsch. Weil dann wüsst Extbase ja auch nicht wo er das zeug hinschreiben soll, nachdem du es vom Request holst und weiterschickst.

mic187 ·

Also ich habe das getestet aber das bringt leider keine änderung.

eigendlich soll es so sein das in die db "content, contentauthor, und communityPosts" eingetragen werden. Die requestsache ist eigendlich nur für die redirect sache auf den communityPosts Controller. Aber irgendwie habe ich glaube einen denkfehler in der sache.

OnkelEdi ·

communityPosts ist doch aber trotzdem keine Property soweit ich sehen kann, oder? Das passt ja auch irgendwie zur Fehlermeldung. was soll den communityPosts sein? content und contentauthor sind die Inhalte aus den beiden Formularfeldern. Aber was soll communityPosts sein? Es wird ja scheinbar versucht etwas in communityPosts zu schreiben wo kein communityPosts ist.
Oder hab ich da nen Knick in der Leitung?

mic187 ·

communityPosts soll die abhänigkeit sein wo der commentar dazugehört. ne du hast bestimmt keinen knick :-) denn habe eben ich. Ich denke ich habe hier irgendwo einen denkfehler.

OnkelEdi ·

😃
ok ich versteh aber auch nicht was du mit "Abhängigkeit" meinst.
Wo holst du dieses "communityPosts" den her? oder wo solls denn hin? 🙂
Vielleicht drück ich mich auch falsch aus.
Aber laut Fehler gibt es das als Property bei dir nicht. Weder im Model seh ich wat, noch kommt da sowas aus dem View/Template zurück. Die einzige Stelle wo das auftaucht ist eben

'communityPosts' => $communityPosts,

Was passiert denn, wenn du das weglässt?

Ansonsten erklär bitte noch mal, ich versteh nämlich echt nicht wozu das ding gut ist 🙂

mic187 ·

also anbei mal der link zur demo seite http://bit.ly/1wrZCcr vieleicht ist es dann einfach zu verstehen was ich meine.

Eigendlich so ähnlich wie ein Blog. Ich kann beiträge erstellen und die dann kommentieren. Un der kommentar muss eben dem beitrag zugeordnet werden.

Test User -> demo:demo

hoffe damit ist es einfacher

OnkelEdi ·

ah ok,

also communityPostsComments ist ein Model und communityPosts ist ein anderes Model... also zwei Paar Schuhe?
Wenn ja, dann hab ich das vorher nicht gecheckt. Und communityPosts brauchst du um nach dem redirect zum richtigen Post zurückzukommen?
Aber extbase weiß wohl an der Stelle wo du das ans array des redirects übergibst nicht wo er das herholen soll. Ich weiß nicht wo das sonst noch liegen kann...
Kann dir aber leider auch grad nicht sagen, was du dagegen tun kannst. 🙂
Kannst du auch die betreffende action im communityPosts Model zeigen...
vielleicht kann er auch da nix mit dem anfangen was du dem redirect mitgibst.

Ergänzung:

so jetzt weiß ich was ich sagen will 🙂

Also bis zum Punkt des Absendens hab ichs verstanden.
Meine Frage jetzt: Was steht im Moment des Redirects in communityPosts drin (oder soll drinstehen)?
Denn das soll, wenn richtig verstanden, dazu dienen zum richtigen Post zurück zu kommen oder?
Und wie soll das communityPosts das du übergibts dann im anderen Controller verarbeitet werden bzw. was soll dort damit passieren?

mic187 ·

hallo also wie du schon sagtest es soll einfach auf den alten post zurückkehren. es soll dort noch den kommentar in den post eintragen, wegen der abhängigkeit bzw. zusammenhang.

Aber ich denke da hat sich irgendwo ein fehler eingeschlichen, weil wenn ich einen beitrag poste dann kommt genau die selber fehlermeldung. dort steht aber nirgends was von communityPosts.

OnkelEdi ·

Hallo,

was steht den in der anderen Fehlermeldung?
Ich glaube du machst vielleicht irgendwo was zu kompliziert.
An dieser Stelle muss ich wohl erst mal kapitulieren 🙂
So gut kenn ich mich dann doch nicht aus. Zumindest komm ich nicht weiter ohne den Rest der Extension.
Wenn du magst kannst du die auch gerne mal schicken. Ansonsten muss hier vielleicht wer anders weiterhelfen. Sorry 🙂

Gruß