<commit_before><?php

class Denkmal_FormAction_EventAdd_Create extends CM_FormAction_Abstract {

	public function __construct() {
		parent::__construct('create');
	}

	public function setup(CM_Form_Abstract $form) {
		$this->required_fields = array('venue', 'date', 'fromTime', 'title');
		parent::setup($form);
	}

	public function process(array $data, CM_Response_View_Form $response, CM_Form_Abstract $form) {
		$data = Denkmal_Params::factory($data);
		$venue = $data->get('venue');
		if (!$venue instanceof Denkmal_Model_Venue) {
			$address = $data->has('venueAddress') ? $data->getString('venueAddress') : null;
			$url = $data->has('venueUrl') ? $data->getString('venueUrl') : null;
			$venueData = array(
				'name'    => (string) $venue,
				'queued'  => true,
				'enabled' => false,
				'address' => $address,
				'url'     => $url,
			);
			$venue = Denkmal_Model_Venue::create($venueData);
		}



		$date = $data->getDateTime('date');
		$from = clone $date;
		$from->add($data->getDateInterval('fromTime'));
		$until = null;
		if ($data->has('untilTime')) {
			$until = clone $date;
			$until->add($data->getDateInterval('untilTime'));
			if ($until < $from) {
				$until->add(new DateInterval('P1D'));
			}
		}

		$descriptionParts = array();
		$descriptionParts[] = $data->getString('title');
		$descriptionParts[] = $data->getString('artists', '');
		$descriptionParts[] = $data->getString('genres', '');
		$descriptionParts[] = $data->getString('urls', '');
		$descriptionParts = array_filter($descriptionParts, 'trim');
		$description = implode(' ', $descriptionParts);

		$eventData = array(
			'venue'       => $venue,
			'from'        => $from,
			'until'       => $until,
			'description' => $description,
			'queued' => true,
			'enabled' => false,
		);
		Denkmal_Model_Event::create($eventData);
	}
}<commit_msg>Check venue name in event add form<commit_after><?php

class Denkmal_FormAction_EventAdd_Create extends CM_FormAction_Abstract {

	public function __construct() {
		parent::__construct('create');
	}

	public function setup(CM_Form_Abstract $form) {
		$this->required_fields = array('venue', 'date', 'fromTime', 'title');
		parent::setup($form);
	}

	protected function _checkData(CM_Params $params, CM_Response_View_Form $response, CM_Form_Abstract $form) {
		$name = $params->get('venue');
		if (!$name instanceof Denkmal_Model_Venue) {
			if ($venue = Denkmal_Model_Venue::findByNameOrAlias($name)) {
				$response->addError('Name already used by venue `' . $venue->getName() . '`', 'venue');
			}
		}
	}

	public function process(array $data, CM_Response_View_Form $response, CM_Form_Abstract $form) {
		$data = Denkmal_Params::factory($data);
		$venue = $data->get('venue');
		if (!$venue instanceof Denkmal_Model_Venue) {
			$address = $data->has('venueAddress') ? $data->getString('venueAddress') : null;
			$url = $data->has('venueUrl') ? $data->getString('venueUrl') : null;
			$venueData = array(
				'name'    => (string) $venue,
				'queued'  => true,
				'enabled' => false,
				'address' => $address,
				'url'     => $url,
			);
			$venue = Denkmal_Model_Venue::create($venueData);
		}

		$date = $data->getDateTime('date');
		$from = clone $date;
		$from->add($data->getDateInterval('fromTime'));
		$until = null;
		if ($data->has('untilTime')) {
			$until = clone $date;
			$until->add($data->getDateInterval('untilTime'));
			if ($until < $from) {
				$until->add(new DateInterval('P1D'));
			}
		}

		$descriptionParts = array();
		$descriptionParts[] = $data->getString('title');
		$descriptionParts[] = $data->getString('artists', '');
		$descriptionParts[] = $data->getString('genres', '');
		$descriptionParts[] = $data->getString('urls', '');
		$descriptionParts = array_filter($descriptionParts, 'trim');
		$description = implode(' ', $descriptionParts);

		$eventData = array(
			'venue'       => $venue,
			'from'        => $from,
			'until'       => $until,
			'description' => $description,
			'queued'      => true,
			'enabled'     => false,
		);
		Denkmal_Model_Event::create($eventData);
	}
}
{'fraction_non_alphanumeric': 0.19207091849298202, 'fraction_numerical': 0.0004924895345973898, 'mean_word_length': 4.445040214477212, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 62, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1086834', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1353, 'n_words': 246}