This repository has been archived by the owner on Jul 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from pinepain/fix_notifiers_calling
Fix notifiers calling behavior
- Loading branch information
Showing
21 changed files
with
455 additions
and
469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/* | ||
+----------------------------------------------------------------------+ | ||
| This file is part of the pinepain/php-weak PHP extension. | | ||
| | | ||
| Copyright (c) 2016 Bogdan Padalko <[email protected]> | | ||
| | | ||
| Licensed under the MIT license: http://opensource.org/licenses/MIT | | ||
| | | ||
| For the full copyright and license information, please view the | | ||
| LICENSE file that was distributed with this source or visit | | ||
| http://opensource.org/licenses/MIT | | ||
+----------------------------------------------------------------------+ | ||
*/ | ||
|
||
#include "php_weak_notifier_exception.h" | ||
#include "php_weak.h" | ||
#include "zend_exceptions.h" | ||
|
||
|
||
zend_class_entry *php_weak_notifier_exception_class_entry; | ||
#define this_ce php_weak_notifier_exception_class_entry | ||
|
||
|
||
static zend_object *php_weak_notifier_exception_ctor(zend_class_entry *ce) /* {{{ */ | ||
{ | ||
zval obj, thrown; | ||
zend_object *object; | ||
|
||
Z_OBJ(obj) = object = ce->parent->create_object(ce); | ||
|
||
array_init_size(&thrown, 0); | ||
zend_update_property(php_weak_notifier_exception_class_entry, &obj, ZEND_STRL("exceptions"), &thrown); | ||
|
||
return object; | ||
} /* }}} */ | ||
|
||
|
||
void php_weak_create_notifier_exception(zval *exception, const char *message, zval *thrown) /* {{{ */ | ||
{ | ||
object_init_ex(exception, this_ce); | ||
zend_update_property_string(zend_ce_exception, exception, ZEND_STRL("message"), message); | ||
zend_update_property(php_weak_notifier_exception_class_entry, exception, ZEND_STRL("exceptions"), thrown); | ||
} /* }}} */ | ||
|
||
static PHP_METHOD(NotifierException, __construct) /* {{{ */ | ||
{ | ||
zend_string *message = NULL; | ||
zend_long code = 0; | ||
|
||
zval tmp; | ||
zval *exceptions = NULL; | ||
zval *previous = NULL; | ||
|
||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|SalO!", &message, &exceptions, &code, &previous, zend_ce_throwable) == FAILURE) { | ||
return; | ||
} | ||
|
||
if (message) { | ||
zend_update_property_str(zend_ce_exception, getThis(), ZEND_STRL("message"), message); | ||
} | ||
|
||
if (exceptions) { | ||
zend_update_property(this_ce, getThis(), ZEND_STRL("exceptions"), exceptions); | ||
} else { | ||
array_init_size(&tmp, 0); | ||
zend_update_property(this_ce, getThis(), ZEND_STRL("exceptions"), &tmp); | ||
} | ||
|
||
if (code) { | ||
zend_update_property_long(zend_ce_exception, getThis(), ZEND_STRL("code"), code); | ||
} | ||
|
||
if (previous) { | ||
zend_update_property(zend_ce_exception, getThis(), ZEND_STRL("previous"), previous); | ||
} | ||
} | ||
|
||
static PHP_METHOD(NotifierException, getExceptions) /* {{{ */ | ||
{ | ||
zval rv; | ||
|
||
if (zend_parse_parameters_none() == FAILURE) { | ||
return; | ||
} | ||
|
||
RETVAL_ZVAL(zend_read_property(php_weak_notifier_exception_class_entry, getThis(), ZEND_STRL("exceptions"), 0, &rv), 1, 0); | ||
} /* }}} */ | ||
|
||
|
||
ZEND_BEGIN_ARG_INFO_EX(arginfo_notifier_exception___construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) | ||
ZEND_ARG_INFO(0, message) | ||
ZEND_ARG_INFO(0, exceptions) | ||
ZEND_ARG_INFO(0, code) | ||
ZEND_ARG_INFO(0, previous) | ||
ZEND_END_ARG_INFO() | ||
|
||
ZEND_BEGIN_ARG_INFO_EX(arginfo_notifier_exception_getExceptions, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0) | ||
ZEND_END_ARG_INFO() | ||
|
||
|
||
static const zend_function_entry php_weak_notifier_exception_methods[] = { /* {{{ */ | ||
PHP_ME(NotifierException, __construct, arginfo_notifier_exception___construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR) | ||
PHP_ME(NotifierException, getExceptions, arginfo_notifier_exception_getExceptions, ZEND_ACC_PUBLIC) | ||
|
||
PHP_FE_END | ||
}; /* }}} */ | ||
|
||
|
||
PHP_MINIT_FUNCTION (php_weak_notifier_exception) /* {{{ */ | ||
{ | ||
zend_class_entry ce; | ||
|
||
INIT_NS_CLASS_ENTRY(ce, PHP_WEAK_NS, "NotifierException", php_weak_notifier_exception_methods); | ||
this_ce = zend_register_internal_class_ex(&ce, zend_ce_exception); | ||
/*this_ce->create_object = php_weak_notifier_exception_ctor;*/ | ||
|
||
zend_declare_property_null(this_ce, ZEND_STRL("exceptions"), ZEND_ACC_PRIVATE); | ||
|
||
|
||
return SUCCESS; | ||
} /* }}} */ | ||
|
||
|
||
/* | ||
* Local variables: | ||
* tab-width: 4 | ||
* c-basic-offset: 4 | ||
* End: | ||
* vim600: noet sw=4 ts=4 fdm=marker | ||
* vim<600: noet sw=4 ts=4 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
+----------------------------------------------------------------------+ | ||
| This file is part of the pinepain/php-weak PHP extension. | | ||
| | | ||
| Copyright (c) 2016 Bogdan Padalko <[email protected]> | | ||
| | | ||
| Licensed under the MIT license: http://opensource.org/licenses/MIT | | ||
| | | ||
| For the full copyright and license information, please view the | | ||
| LICENSE file that was distributed with this source or visit | | ||
| http://opensource.org/licenses/MIT | | ||
+----------------------------------------------------------------------+ | ||
*/ | ||
|
||
#ifndef PHP_WEAK_NOTIFIER_EXCEPTION_H | ||
#define PHP_WEAK_NOTIFIER_EXCEPTION_H | ||
|
||
#include "php.h" | ||
|
||
#ifdef ZTS | ||
#include "TSRM.h" | ||
#endif | ||
|
||
extern zend_class_entry *php_weak_notifier_exception_class_entry; | ||
|
||
void php_weak_create_notifier_exception(zval *exception, const char *message, zval *thrown); | ||
|
||
PHP_MINIT_FUNCTION(php_weak_notifier_exception); | ||
|
||
|
||
#endif /* PHP_WEAK_NOTIFIER_EXCEPTION_H */ | ||
|
||
|
||
/* | ||
* Local variables: | ||
* tab-width: 4 | ||
* c-basic-offset: 4 | ||
* End: | ||
* vim600: noet sw=4 ts=4 fdm=marker | ||
* vim<600: noet sw=4 ts=4 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
|
||
namespace Weak; | ||
|
||
|
||
use Exception; | ||
|
||
|
||
class NotifierException extends Exception | ||
{ | ||
private $exceptions = []; | ||
|
||
/** | ||
* Get exceptions thrown from notifiers | ||
* | ||
* @return array | ||
*/ | ||
public function getExceptions() : array | ||
{ | ||
return $this->exceptions; | ||
} | ||
} |
Oops, something went wrong.